Commit 0cba114f authored by Dave Jones's avatar Dave Jones

[PATCH] plug DRM memory leak on exit paths.

Spotted by Oleg Drokin
parent 4c32714d
...@@ -581,8 +581,10 @@ static int __init drm_init( void ) ...@@ -581,8 +581,10 @@ static int __init drm_init( void )
init_timer( &dev->timer ); init_timer( &dev->timer );
init_waitqueue_head( &dev->context_wait ); init_waitqueue_head( &dev->context_wait );
if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0) if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0) {
return -EPERM; retcode = -EPERM;
goto fail_reg;
}
dev->device = MKDEV(DRM_MAJOR, DRM(minor)[i] ); dev->device = MKDEV(DRM_MAJOR, DRM(minor)[i] );
dev->name = DRIVER_NAME; dev->name = DRIVER_NAME;
...@@ -591,9 +593,8 @@ static int __init drm_init( void ) ...@@ -591,9 +593,8 @@ static int __init drm_init( void )
#if __MUST_HAVE_AGP #if __MUST_HAVE_AGP
if ( dev->agp == NULL ) { if ( dev->agp == NULL ) {
DRM_ERROR( "Cannot initialize the agpgart module.\n" ); DRM_ERROR( "Cannot initialize the agpgart module.\n" );
DRM(stub_unregister)(DRM(minor)[i]); retcode = -ENOMEM;
DRM(takedown)( dev ); goto fail;
return -ENOMEM;
} }
#endif #endif
#if __REALLY_HAVE_MTRR #if __REALLY_HAVE_MTRR
...@@ -609,9 +610,7 @@ static int __init drm_init( void ) ...@@ -609,9 +610,7 @@ static int __init drm_init( void )
retcode = DRM(ctxbitmap_init)( dev ); retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) { if( retcode ) {
DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
DRM(stub_unregister)(DRM(minor)[i]); goto fail;
DRM(takedown)( dev );
return retcode;
} }
#endif #endif
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n", DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
...@@ -626,6 +625,15 @@ static int __init drm_init( void ) ...@@ -626,6 +625,15 @@ static int __init drm_init( void )
DRIVER_POSTINIT(); DRIVER_POSTINIT();
return 0; return 0;
fail:
DRM(stub_unregister)(DRM(minor)[i]);
DRM(takedown)( dev );
fail_reg:
kfree (DRM(device));
kfree (DRM(minor));
return retcode;
} }
/* drm_cleanup is called via cleanup_module at module unload time. /* drm_cleanup is called via cleanup_module at module unload time.
......
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