Commit 03047cdf authored by Michel Dänzer's avatar Michel Dänzer Committed by Dave Airlie

drm/radeon/kms: Test rdev->bios centrally in combios_get_table_offset().

It's happened time and time again (most recently with the support for EDID
hardcoded in the BIOS ROM) that new code didn't check for rdev->bios being
non-NULL before triggering dereferences of it. This would result in an
oops/panic on setups with no BIOS ROM. Hopefully this central test will be
more robust.
Signed-off-by: default avatarMichel Dänzer <daenzer@vmware.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 961fb597
...@@ -150,6 +150,9 @@ static uint16_t combios_get_table_offset(struct drm_device *dev, ...@@ -150,6 +150,9 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
int rev; int rev;
uint16_t offset = 0, check_offset; uint16_t offset = 0, check_offset;
if (!rdev->bios)
return 0;
switch (table) { switch (table) {
/* absolute offset tables */ /* absolute offset tables */
case COMBIOS_ASIC_INIT_1_TABLE: case COMBIOS_ASIC_INIT_1_TABLE:
...@@ -621,9 +624,6 @@ bool radeon_combios_get_clock_info(struct drm_device *dev) ...@@ -621,9 +624,6 @@ bool radeon_combios_get_clock_info(struct drm_device *dev)
int8_t rev; int8_t rev;
uint16_t sclk, mclk; uint16_t sclk, mclk;
if (rdev->bios == NULL)
return false;
pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE); pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
if (pll_info) { if (pll_info) {
rev = RBIOS8(pll_info); rev = RBIOS8(pll_info);
...@@ -748,9 +748,6 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct ...@@ -748,9 +748,6 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
if (!p_dac) if (!p_dac)
return NULL; return NULL;
if (rdev->bios == NULL)
goto out;
/* check CRT table */ /* check CRT table */
dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
if (dac_info) { if (dac_info) {
...@@ -767,7 +764,6 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct ...@@ -767,7 +764,6 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
found = 1; found = 1;
} }
out:
if (!found) /* fallback to defaults */ if (!found) /* fallback to defaults */
radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac); radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac);
...@@ -781,9 +777,6 @@ radeon_combios_get_tv_info(struct radeon_device *rdev) ...@@ -781,9 +777,6 @@ radeon_combios_get_tv_info(struct radeon_device *rdev)
uint16_t tv_info; uint16_t tv_info;
enum radeon_tv_std tv_std = TV_STD_NTSC; enum radeon_tv_std tv_std = TV_STD_NTSC;
if (rdev->bios == NULL)
return tv_std;
tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
if (tv_info) { if (tv_info) {
if (RBIOS8(tv_info + 6) == 'T') { if (RBIOS8(tv_info + 6) == 'T') {
...@@ -887,9 +880,6 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -887,9 +880,6 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
if (!tv_dac) if (!tv_dac)
return NULL; return NULL;
if (rdev->bios == NULL)
goto out;
/* first check TV table */ /* first check TV table */
dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
if (dac_info) { if (dac_info) {
...@@ -951,7 +941,6 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -951,7 +941,6 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
} }
} }
out:
if (!found) /* fallback to defaults */ if (!found) /* fallback to defaults */
radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
...@@ -1039,11 +1028,6 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder ...@@ -1039,11 +1028,6 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
int tmp, i; int tmp, i;
struct radeon_encoder_lvds *lvds = NULL; struct radeon_encoder_lvds *lvds = NULL;
if (rdev->bios == NULL) {
lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
goto out;
}
lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE); lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
if (lcd_info) { if (lcd_info) {
...@@ -1144,7 +1128,7 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder ...@@ -1144,7 +1128,7 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
DRM_INFO("No panel info found in BIOS\n"); DRM_INFO("No panel info found in BIOS\n");
lvds = radeon_legacy_get_lvds_info_from_regs(rdev); lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
} }
out:
if (lvds) if (lvds)
encoder->native_mode = lvds->native_mode; encoder->native_mode = lvds->native_mode;
return lvds; return lvds;
...@@ -1196,9 +1180,6 @@ bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, ...@@ -1196,9 +1180,6 @@ bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
int i, n; int i, n;
uint8_t ver; uint8_t ver;
if (rdev->bios == NULL)
return false;
tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE); tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
if (tmds_info) { if (tmds_info) {
...@@ -1278,9 +1259,6 @@ bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder ...@@ -1278,9 +1259,6 @@ bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder
enum radeon_combios_ddc gpio; enum radeon_combios_ddc gpio;
struct radeon_i2c_bus_rec i2c_bus; struct radeon_i2c_bus_rec i2c_bus;
if (rdev->bios == NULL)
return false;
tmds->i2c_bus = NULL; tmds->i2c_bus = NULL;
if (rdev->flags & RADEON_IS_IGP) { if (rdev->flags & RADEON_IS_IGP) {
offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
...@@ -2006,9 +1984,6 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) ...@@ -2006,9 +1984,6 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
struct radeon_i2c_bus_rec ddc_i2c; struct radeon_i2c_bus_rec ddc_i2c;
struct radeon_hpd hpd; struct radeon_hpd hpd;
if (rdev->bios == NULL)
return false;
conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE); conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
if (conn_info) { if (conn_info) {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
...@@ -2385,10 +2360,6 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev) ...@@ -2385,10 +2360,6 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
rdev->pm.default_power_state = NULL; rdev->pm.default_power_state = NULL;
rdev->pm.current_power_state = NULL; rdev->pm.current_power_state = NULL;
/* XXX mac/sparc cards */
if (rdev->bios == NULL)
goto default_mode;
if (rdev->flags & RADEON_IS_MOBILITY) { if (rdev->flags & RADEON_IS_MOBILITY) {
offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE); offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
if (offset) { if (offset) {
...@@ -2545,9 +2516,6 @@ bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder) ...@@ -2545,9 +2516,6 @@ bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
uint32_t reg, val, and_mask, or_mask; uint32_t reg, val, and_mask, or_mask;
struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
if (rdev->bios == NULL)
return false;
if (!tmds) if (!tmds)
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment