Commit 4722f463 authored by Christian König's avatar Christian König Committed by Alex Deucher

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: ab50cb9d ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()")
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Tested-by: default avatarJan Stancek <jstancek@redhat.com>
Tested-by: default avatarBorislav Petkov <bp@suse.de>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9a458402
...@@ -666,18 +666,18 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) ...@@ -666,18 +666,18 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
if (unlikely(!fpriv)) { if (unlikely(!fpriv)) {
r = -ENOMEM; r = -ENOMEM;
goto out_suspend; goto err_suspend;
} }
if (rdev->accel_working) { if (rdev->accel_working) {
vm = &fpriv->vm; vm = &fpriv->vm;
r = radeon_vm_init(rdev, vm); r = radeon_vm_init(rdev, vm);
if (r) if (r)
goto out_fpriv; goto err_fpriv;
r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
if (r) if (r)
goto out_vm_fini; goto err_vm_fini;
/* map the ib pool buffer read only into /* map the ib pool buffer read only into
* virtual address space */ * virtual address space */
...@@ -685,7 +685,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) ...@@ -685,7 +685,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
rdev->ring_tmp_bo.bo); rdev->ring_tmp_bo.bo);
if (!vm->ib_bo_va) { if (!vm->ib_bo_va) {
r = -ENOMEM; r = -ENOMEM;
goto out_vm_fini; goto err_vm_fini;
} }
r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va, r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va,
...@@ -693,19 +693,21 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) ...@@ -693,19 +693,21 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
RADEON_VM_PAGE_READABLE | RADEON_VM_PAGE_READABLE |
RADEON_VM_PAGE_SNOOPED); RADEON_VM_PAGE_SNOOPED);
if (r) if (r)
goto out_vm_fini; goto err_vm_fini;
} }
file_priv->driver_priv = fpriv; file_priv->driver_priv = fpriv;
} }
if (!r) pm_runtime_mark_last_busy(dev->dev);
goto out_suspend; pm_runtime_put_autosuspend(dev->dev);
return 0;
out_vm_fini: err_vm_fini:
radeon_vm_fini(rdev, vm); radeon_vm_fini(rdev, vm);
out_fpriv: err_fpriv:
kfree(fpriv); kfree(fpriv);
out_suspend:
err_suspend:
pm_runtime_mark_last_busy(dev->dev); pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev); pm_runtime_put_autosuspend(dev->dev);
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment