From a9327b111058afdb622bd9a1fddbf9e3273c453b Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sat, 15 Nov 2014 09:25:40 -0600 Subject: [PATCH] radeon_hd: Add additional sanity checks * Prevents negative array index read (again) * Clear display_mode struct before lvds read - CID 1108403 --- src/add-ons/accelerants/radeon_hd/connector.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/add-ons/accelerants/radeon_hd/connector.cpp b/src/add-ons/accelerants/radeon_hd/connector.cpp index 470421ed64..d3d44bdc47 100644 --- a/src/add-ons/accelerants/radeon_hd/connector.cpp +++ b/src/add-ons/accelerants/radeon_hd/connector.cpp @@ -9,6 +9,7 @@ #include "connector.h" +#include #include #include "accelerant_protos.h" @@ -152,6 +153,8 @@ connector_read_edid(uint32 connectorIndex, edid1_info* edid) bool connector_read_mode_lvds(uint32 connectorIndex, display_mode* mode) { + assert(mode); + uint8 dceMajor; uint8 dceMinor; int index = GetIndexIntoMasterTable(DATA, LVDS_Info); @@ -162,6 +165,9 @@ connector_read_mode_lvds(uint32 connectorIndex, display_mode* mode) struct _ATOM_LVDS_INFO_V12 info_12; }; + // Wipe out display_mode + memset(mode, 0, sizeof(display_mode)); + if (atom_parse_data_header(gAtomContext, index, NULL, &dceMajor, &dceMinor, &offset) == B_OK) { @@ -379,8 +385,10 @@ gpio_i2c_populate() break; } } - if (gpioIndex < 0) + if (gpioIndex < 0) { ERROR("%s: ERROR: Out of space for additional GPIO pins!\n", __func__); + return B_ERROR; + } for (uint32 i = 0; i < numIndices; i++) { if (gGPIOInfo[gpioIndex]->valid) {