diff options
author | Eric Anholt <anholt@freebsd.org> | 2005-11-08 01:12:08 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2005-11-08 01:12:08 +0000 |
commit | 145b23b55220bdfc6639d3279ad96310faa650a3 (patch) | |
tree | 1745a9a88913e2e75a616a110a17acc651d881cf /bsd-core | |
parent | 3fce085e13d6559adaed98420c35a1313636cff5 (diff) |
Correct a recursion on non-recursive mutex in drm_addmap from radeon's
firstopen, by making drm_addmap require the drm device lock to be held.
Also, make matching of kernel maps match linux by requiring shm matches
to have the contains_lock flag set if the offset doesn't match.
Diffstat (limited to 'bsd-core')
-rw-r--r-- | bsd-core/drm_bufs.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c index 0e3fc1fd..f088703c 100644 --- a/bsd-core/drm_bufs.c +++ b/bsd-core/drm_bufs.c @@ -127,17 +127,17 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size, */ if (type == _DRM_REGISTERS || type == _DRM_FRAME_BUFFER || type == _DRM_SHM) { - DRM_LOCK(); TAILQ_FOREACH(map, &dev->maplist, link) { - if (map->type == type && - (map->offset == offset || map->type == _DRM_SHM)) { + if (map->type == type && (map->offset == offset || + (map->type == _DRM_SHM && + map->flags == _DRM_CONTAINS_LOCK))) { map->size = size; DRM_DEBUG("Found kernel map %d\n", type); goto done; } } - DRM_UNLOCK(); } + DRM_UNLOCK(); /* Allocate a new map structure, fill it in, and do any type-specific * initialization necessary. @@ -236,7 +236,6 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size, done: /* Jumped to, with lock held, when a kernel map is found. */ - DRM_UNLOCK(); DRM_DEBUG("Added map %d 0x%lx/0x%lx\n", map->type, map->offset, map->size); @@ -261,8 +260,10 @@ int drm_addmap_ioctl(DRM_IOCTL_ARGS) if (!DRM_SUSER(p) && request.type != _DRM_AGP) return DRM_ERR(EACCES); + DRM_LOCK(); err = drm_addmap(dev, request.offset, request.size, request.type, request.flags, &map); + DRM_UNLOCK(); if (err != 0) return err; |