Skip to content

Commit 4722f46

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/radeon: fix error handling in radeon_driver_open_kms
The return value was never initialized so the cleanup code executed when it isn't even necessary. Just add proper error handling. Fixes: ab50cb9 ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()") Signed-off-by: Christian König <[email protected]> Tested-by: Jan Stancek <[email protected]> Tested-by: Borislav Petkov <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 9a45840 commit 4722f46

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/gpu/drm/radeon/radeon_kms.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,46 +666,48 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
666666
fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
667667
if (unlikely(!fpriv)) {
668668
r = -ENOMEM;
669-
goto out_suspend;
669+
goto err_suspend;
670670
}
671671

672672
if (rdev->accel_working) {
673673
vm = &fpriv->vm;
674674
r = radeon_vm_init(rdev, vm);
675675
if (r)
676-
goto out_fpriv;
676+
goto err_fpriv;
677677

678678
r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
679679
if (r)
680-
goto out_vm_fini;
680+
goto err_vm_fini;
681681

682682
/* map the ib pool buffer read only into
683683
* virtual address space */
684684
vm->ib_bo_va = radeon_vm_bo_add(rdev, vm,
685685
rdev->ring_tmp_bo.bo);
686686
if (!vm->ib_bo_va) {
687687
r = -ENOMEM;
688-
goto out_vm_fini;
688+
goto err_vm_fini;
689689
}
690690

691691
r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va,
692692
RADEON_VA_IB_OFFSET,
693693
RADEON_VM_PAGE_READABLE |
694694
RADEON_VM_PAGE_SNOOPED);
695695
if (r)
696-
goto out_vm_fini;
696+
goto err_vm_fini;
697697
}
698698
file_priv->driver_priv = fpriv;
699699
}
700700

701-
if (!r)
702-
goto out_suspend;
701+
pm_runtime_mark_last_busy(dev->dev);
702+
pm_runtime_put_autosuspend(dev->dev);
703+
return 0;
703704

704-
out_vm_fini:
705+
err_vm_fini:
705706
radeon_vm_fini(rdev, vm);
706-
out_fpriv:
707+
err_fpriv:
707708
kfree(fpriv);
708-
out_suspend:
709+
710+
err_suspend:
709711
pm_runtime_mark_last_busy(dev->dev);
710712
pm_runtime_put_autosuspend(dev->dev);
711713
return r;

0 commit comments

Comments
 (0)