Skip to contentSkip to conversation

drivers/gpu/drm/radeon/radeon_device.c: move a dereference below a NULL test

PATCH Darren Jenkins 1 participant 1 message Dec 24, 2009

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

If a NULL value is possible, the dereference should only occur after the NULL test.

Coverity CID: 13335

(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/radeon_device.c
index 02bcdb1..c0104b0 100644

drivers/gpu/drm/radeon/radeon_device.c +0 -0
@@ -663,16 +663,18 @@ void radeon_device_fini(struct radeon_device

*rdev)
*/
int radeon_suspend_kms(struct drm_device *dev, pm_message_t state) {
- struct radeon_device *rdev = dev->dev_private;
+ struct radeon_device *rdev;
struct drm_crtc *crtc;
int r;

-	if (dev == NULL || rdev == NULL) {
+	if (dev == NULL || dev->dev_private == NULL) {

return -ENODEV;
}
if (state.event == PM_EVENT_PRETHAW) {
return 0;
}
+ rdev = dev->dev_private;
+
/* unpin the front buffers */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->fb);