Skip to content

Commit

Permalink
drm: Fix cleanup if device initialization fails
Browse files Browse the repository at this point in the history
This plugs some memory leaks.
  • Loading branch information
dumbbell committed Aug 25, 2013
1 parent d1f3b5c commit 3462fe4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions sys/dev/drm2/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,22 @@ int drm_attach(device_t kdev, drm_pci_id_list_t *idlist)
sx_init(&dev->dev_struct_lock, "drmslk");

error = drm_load(dev);
if (error == 0)
error = drm_create_cdevs(kdev);
if (error)
goto error;

error = drm_create_cdevs(kdev);
if (error)
goto error;

return (error);
error:
if (dev->irqr) {
bus_release_resource(dev->device, SYS_RES_IRQ,
dev->irqrid, dev->irqr);
}
if (dev->msi_enabled) {
pci_release_msi(dev->device);
}
return (error);
}

Expand Down Expand Up @@ -572,7 +586,7 @@ static int drm_load(struct drm_device *dev)
DRM_ERROR("Request to enable bus-master failed.\n");
DRM_UNLOCK(dev);
if (retcode != 0)
goto error;
goto error1;
}

DRM_INFO("Initialized %s %d.%d.%d %s\n",
Expand All @@ -586,7 +600,9 @@ static int drm_load(struct drm_device *dev)

error1:
delete_unrhdr(dev->drw_unrhdr);
drm_gem_destroy(dev);
error:
drm_ctxbitmap_cleanup(dev);
drm_sysctl_cleanup(dev);
DRM_LOCK(dev);
drm_lastclose(dev);
Expand Down

0 comments on commit 3462fe4

Please sign in to comment.