Skip to content

Commit 745bae7

Browse files
fifteenhexalexdeucher
authored andcommitted
drm/radeon: Remove calls to drm_put_dev()
Since the allocation of the drivers main structure was changed to devm_drm_dev_alloc() drm_put_dev()'ing to trigger it to be free'd should be done by devres. However, drm_put_dev() is still in the probe error and device remove paths. When the driver fails to probe warnings like the following are shown because devres is trying to drm_put_dev() after the driver already did it. [ 5.642230] radeon 0000:01:05.0: probe with driver radeon failed with error -22 [ 5.649605] ------------[ cut here ]------------ [ 5.649607] refcount_t: underflow; use-after-free. [ 5.649620] WARNING: CPU: 0 PID: 357 at lib/refcount.c:28 refcount_warn_saturate+0xbe/0x110 Fixes: a9ed2f0 ("drm/radeon: change drm_dev_alloc to devm_drm_dev_alloc") Signed-off-by: Daniel Palmer <daniel@0x0f.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 3eb8c0b4c091da0a623ade0d3ee7aa4a93df1ea4)
1 parent 3328443 commit 745bae7

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

drivers/gpu/drm/radeon/radeon_drv.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,17 @@ static int radeon_pci_probe(struct pci_dev *pdev,
314314

315315
ret = pci_enable_device(pdev);
316316
if (ret)
317-
goto err_free;
317+
return ret;
318318

319319
pci_set_drvdata(pdev, ddev);
320320

321321
ret = radeon_driver_load_kms(ddev, flags);
322322
if (ret)
323-
goto err_agp;
323+
goto err;
324324

325325
ret = drm_dev_register(ddev, flags);
326326
if (ret)
327-
goto err_agp;
327+
goto err;
328328

329329
if (rdev->mc.real_vram_size <= (8 * 1024 * 1024))
330330
format = drm_format_info(DRM_FORMAT_C8);
@@ -337,30 +337,14 @@ static int radeon_pci_probe(struct pci_dev *pdev,
337337

338338
return 0;
339339

340-
err_agp:
340+
err:
341341
pci_disable_device(pdev);
342-
err_free:
343-
drm_dev_put(ddev);
344342
return ret;
345343
}
346344

347-
static void
348-
radeon_pci_remove(struct pci_dev *pdev)
349-
{
350-
struct drm_device *dev = pci_get_drvdata(pdev);
351-
352-
drm_put_dev(dev);
353-
}
354-
355345
static void
356346
radeon_pci_shutdown(struct pci_dev *pdev)
357347
{
358-
/* if we are running in a VM, make sure the device
359-
* torn down properly on reboot/shutdown
360-
*/
361-
if (radeon_device_is_virtual())
362-
radeon_pci_remove(pdev);
363-
364348
#if defined(CONFIG_PPC64) || defined(CONFIG_MACH_LOONGSON64)
365349
/*
366350
* Some adapters need to be suspended before a
@@ -613,7 +597,6 @@ static struct pci_driver radeon_kms_pci_driver = {
613597
.name = DRIVER_NAME,
614598
.id_table = pciidlist,
615599
.probe = radeon_pci_probe,
616-
.remove = radeon_pci_remove,
617600
.shutdown = radeon_pci_shutdown,
618601
.driver.pm = &radeon_pm_ops,
619602
};

0 commit comments

Comments
 (0)