drm/radeon/kms: Fix NULL ptr dereference
authorJerome Glisse <jglisse@redhat.com>
Wed, 9 Dec 2009 16:39:16 +0000 (17:39 +0100)
committerDave Airlie <airlied@redhat.com>
Thu, 10 Dec 2009 05:09:06 +0000 (15:09 +1000)
radeon_atombios_fini might be call while there is not valid
atombios structure allocated, thus test for a not null ptr
before trying to access this structure.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/gpu/drm/radeon/radeon_device.c

index 7e55647f118ec2c4cc14173fa248180c9e60676f..410859ee112f9dd52169ab14e098afa00a0e5144 100644 (file)
@@ -487,8 +487,10 @@ int radeon_atombios_init(struct radeon_device *rdev)
 
 void radeon_atombios_fini(struct radeon_device *rdev)
 {
-       kfree(rdev->mode_info.atom_context->scratch);
-       kfree(rdev->mode_info.atom_context);
+       if (rdev->mode_info.atom_context) {
+               kfree(rdev->mode_info.atom_context->scratch);
+               kfree(rdev->mode_info.atom_context);
+       }
        kfree(rdev->mode_info.atom_card_info);
 }