From: davej@codemonkey.org.uk
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: plug DRM memory leak on exit paths.
Date: Mon, 24 Mar 2003 16:41:46 +0000 [thread overview]
Message-ID: <200303241641.h2OGfx35008214@deviant.impure.org.uk> (raw)
Spotted by Oleg Drokin
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/drivers/char/drm/drm_drv.h linux-2.5/drivers/char/drm/drm_drv.h
--- bk-linus/drivers/char/drm/drm_drv.h 2003-03-08 09:56:59.000000000 +0000
+++ linux-2.5/drivers/char/drm/drm_drv.h 2003-03-17 23:42:16.000000000 +0000
@@ -581,8 +581,10 @@ static int __init drm_init( void )
init_timer( &dev->timer );
init_waitqueue_head( &dev->context_wait );
- if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
- return -EPERM;
+ if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0) {
+ retcode = -EPERM;
+ goto fail_reg;
+ }
dev->device = MKDEV(DRM_MAJOR, DRM(minor)[i] );
dev->name = DRIVER_NAME;
@@ -591,9 +593,8 @@ static int __init drm_init( void )
#if __MUST_HAVE_AGP
if ( dev->agp == NULL ) {
DRM_ERROR( "Cannot initialize the agpgart module.\n" );
- DRM(stub_unregister)(DRM(minor)[i]);
- DRM(takedown)( dev );
- return -ENOMEM;
+ retcode = -ENOMEM;
+ goto fail;
}
#endif
#if __REALLY_HAVE_MTRR
@@ -609,9 +610,7 @@ static int __init drm_init( void )
retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) {
DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
- DRM(stub_unregister)(DRM(minor)[i]);
- DRM(takedown)( dev );
- return retcode;
+ goto fail;
}
#endif
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
@@ -626,6 +625,15 @@ static int __init drm_init( void )
DRIVER_POSTINIT();
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.
reply other threads:[~2003-03-24 16:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200303241641.h2OGfx35008214@deviant.impure.org.uk \
--to=davej@codemonkey.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®