summaryrefslogtreecommitdiff
path: root/bsd-core/drm_drv.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2003-10-20 05:09:21 +0000
committerEric Anholt <anholt@freebsd.org>2003-10-20 05:09:21 +0000
commitea7b4fdc225ebbbfd77f875fd3bfcfbdcfa9a1f7 (patch)
treea37f442a37d9e577110812486410c4c023bf43e6 /bsd-core/drm_drv.c
parent6b0424fdcdec9d12943718e4542659c8bca019da (diff)
Fix the possibility of sleeping with locks held in sysctls by copying the
data into temporary variables with the lock held then outputting to sysctls with the lock released. Rearranged a little extra code to aid this. Note that drm_memory_debug.h hasn't had this fix applied, but I consider that code to be just about dead anyway.
Diffstat (limited to 'bsd-core/drm_drv.c')
-rw-r--r--bsd-core/drm_drv.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 269f4225..7d753836 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -472,11 +472,6 @@ static int DRM(setup)( drm_device_t *dev )
dev->magiclist[i].tail = NULL;
}
- dev->maplist = DRM(calloc)(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
- if (dev->maplist == NULL)
- return DRM_ERR(ENOMEM);
- TAILQ_INIT(dev->maplist);
-
dev->lock.hw_lock = NULL;
dev->lock.lock_queue = 0;
dev->irq = 0;
@@ -591,8 +586,6 @@ static int DRM(takedown)( drm_device_t *dev )
DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
}
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
- dev->maplist = NULL;
}
#if __HAVE_DMA
@@ -647,6 +640,14 @@ static int DRM(init)( device_t nbdev )
#elif defined(__NetBSD__)
unit = minor(dev->device.dv_unit);
#endif
+
+ dev->maplist = DRM(calloc)(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ if (dev->maplist == NULL) {
+ retcode = ENOMEM;
+ goto error;
+ }
+ TAILQ_INIT(dev->maplist);
+
dev->name = DRIVER_NAME;
DRM(mem_init)();
DRM(sysctl_init)(dev);
@@ -680,6 +681,7 @@ static int DRM(init)( device_t nbdev )
goto error;
}
#endif
+
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
DRIVER_NAME,
DRIVER_MAJOR,
@@ -703,6 +705,7 @@ error:
mtx_destroy(&dev->dev_lock);
#endif
#endif
+ DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
return retcode;
}
@@ -749,6 +752,7 @@ static void DRM(cleanup)(drm_device_t *dev)
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
mtx_destroy(&dev->dev_lock);
#endif
+ DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
}