Skip to contentSkip to conversation

drivers/gpu/drm/radeon/radeon_cp.c: check for invalid radeon family

PATCH Darren Jenkins 2 participants 2 messages Dec 24, 2009 – Jan 13, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

If there is an invalid radeon family the fw_name is NULL and causes an NULL pointer dereference.
This just adds a check for something unexpected.

Coverity CID: 13252

(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/radeon_cp.c
index 0b2f9c2..1e66337 100644

drivers/gpu/drm/radeon/radeon_cp.c +0 -0
@@ -531,6 +531,8 @@ static int

radeon_cp_init_microcode(drm_radeon_private_t *dev_priv)
((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV570)) {
DRM_INFO("Loading R500 Microcode\n");
fw_name = FIRMWARE_R520;
+ } else {
+ return -EINVAL;
}

err = request_firmware(&dev_priv->me_fw, fw_name, &pdev->dev);

#1 lore raw
Quoted 21 lines · Darren Jenkins

If there is an invalid radeon family the fw_name is NULL and causes an NULL pointer dereference.
This just adds a check for something unexpected.

Coverity CID: 13252

drivers/gpu/drm/radeon/radeon_cp.c +2 -0
index 0b2f9c2..1e66337 100644
@@ -531,6 +531,8 @@ static int
 radeon_cp_init_microcode(drm_radeon_private_t *dev_priv)
 		   ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV570)) {
 		DRM_INFO("Loading R500 Microcode\n");
 		fw_name = FIRMWARE_R520;
+	} else {
+		return -EINVAL;
 	}
 
Quoted 3 lines

err = request_firmware(&dev_priv->me_fw, fw_name, &pdev->dev);

Someone should take the job to clear the if forrest and replace it with switch()/case.

just my 2 cents,
wh

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
--