Commit 9c89bd10 authored by Linus Torvalds's avatar Linus Torvalds

Merge with DRI CVS tree: fix use-after-free bug in DRM(takedown)

parent 113dafa7
...@@ -452,51 +452,49 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -452,51 +452,49 @@ static int DRM(takedown)( drm_device_t *dev )
} }
if( dev->maplist ) { if( dev->maplist ) {
for(list = dev->maplist->head.next; list_for_each_safe( list, list_next, &dev->maplist->head ) {
list != &dev->maplist->head;
list = list_next) {
list_next = list->next;
r_list = (drm_map_list_t *)list; r_list = (drm_map_list_t *)list;
map = r_list->map;
DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS);
if(!map) continue;
switch ( map->type ) { if ( ( map = r_list->map ) ) {
case _DRM_REGISTERS: switch ( map->type ) {
case _DRM_FRAME_BUFFER: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER:
#if __REALLY_HAVE_MTRR #if __REALLY_HAVE_MTRR
if ( map->mtrr >= 0 ) { if ( map->mtrr >= 0 ) {
int retcode; int retcode;
retcode = mtrr_del( map->mtrr, retcode = mtrr_del( map->mtrr,
map->offset, map->offset,
map->size ); map->size );
DRM_DEBUG( "mtrr_del=%d\n", retcode ); DRM_DEBUG( "mtrr_del=%d\n", retcode );
} }
#endif #endif
DRM(ioremapfree)( map->handle, map->size, dev ); DRM(ioremapfree)( map->handle, map->size, dev );
break; break;
case _DRM_SHM: case _DRM_SHM:
vfree(map->handle); vfree(map->handle);
break; break;
case _DRM_AGP: case _DRM_AGP:
/* Do nothing here, because this is all /* Do nothing here, because this is all
* handled in the AGP/GART driver. * handled in the AGP/GART driver.
*/ */
break; break;
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
/* Handle it, but do nothing, if HAVE_SG /* Handle it, but do nothing, if HAVE_SG
* isn't defined. * isn't defined.
*/ */
#if __HAVE_SG #if __HAVE_SG
if(dev->sg) { if(dev->sg) {
DRM(sg_cleanup)(dev->sg); DRM(sg_cleanup)(dev->sg);
dev->sg = NULL; dev->sg = NULL;
} }
#endif #endif
break; break;
}
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
} }
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); list_del( list );
DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS);
} }
DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
dev->maplist = NULL; dev->maplist = NULL;
......
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