Merge branch 'drm-next-3.9' of git://people.freedesktop.org/~agd5f/linux into drm...
[~shefty/rdma-dev.git] / drivers / gpu / drm / radeon / radeon_device.c
index 8794de10a6c7f3019a54c4c1b444603c27e19283..44b8034a400d297dcba86012c8dd797f72a6af28 100644 (file)
@@ -759,6 +759,11 @@ int radeon_atombios_init(struct radeon_device *rdev)
        atom_card_info->pll_write = cail_pll_write;
 
        rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios);
+       if (!rdev->mode_info.atom_context) {
+               radeon_atombios_fini(rdev);
+               return -ENOMEM;
+       }
+
        mutex_init(&rdev->mode_info.atom_context->mutex);
        radeon_atom_initialize_bios_scratch_regs(rdev->ddev);
        atom_allocate_fb_scratch(rdev->mode_info.atom_context);
@@ -778,9 +783,11 @@ void radeon_atombios_fini(struct radeon_device *rdev)
 {
        if (rdev->mode_info.atom_context) {
                kfree(rdev->mode_info.atom_context->scratch);
-               kfree(rdev->mode_info.atom_context);
        }
+       kfree(rdev->mode_info.atom_context);
+       rdev->mode_info.atom_context = NULL;
        kfree(rdev->mode_info.atom_card_info);
+       rdev->mode_info.atom_card_info = NULL;
 }
 
 /* COMBIOS */