[Jfs-patches] [PATCH] fix block_device leak in external log handling
Brought to you by:
blaschke-oss,
shaggyk
From: Christoph H. <hc...@in...> - 2002-05-22 16:14:53
|
Fix the struct block_device leak also for 2.4 and sanitze labels. Index: fs/jfs/jfs_logmgr.c =================================================================== RCS file: /usr/cvs/jfs/linux24/fs/jfs/jfs_logmgr.c,v retrieving revision 1.35 diff -u -u -r1.35 jfs_logmgr.c --- fs/jfs/jfs_logmgr.c 21 May 2002 19:54:15 -0000 1.35 +++ fs/jfs/jfs_logmgr.c 22 May 2002 12:35:12 -0000 @@ -1083,7 +1083,7 @@ * initialize log. */ if ((rc = lmLogInit(log))) - goto errout10; + goto free; goto out; /* @@ -1099,12 +1099,12 @@ if (!(bdev = bdget(kdev_t_to_nr(JFS_SBI(sb)->logdev)))) { rc = ENODEV; - goto errout10; + goto free; } if ((rc = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_FS))) { rc = -rc; - goto errout10; + goto bdput; } log->sb = sb; /* This should be a list */ @@ -1116,13 +1116,13 @@ * initialize log: */ if ((rc = lmLogInit(log))) - goto errout20; + goto close; /* * add file system to log active file system list */ if ((rc = lmLogFileSystem(log, JFS_SBI(sb)->uuid, 1))) - goto errout30; + goto shutdown; out: jFYI(1, ("lmLogOpen: exit(0)\n")); @@ -1132,13 +1132,16 @@ /* * unwind on error */ - errout30: /* unwind lbmLogInit() */ + shutdown: /* unwind lbmLogInit() */ lbmLogShutdown(log); - errout20: /* close external log device */ + close: /* close external log device */ blkdev_put(bdev, BDEV_FS); - errout10: /* free log descriptor */ + bdput: + bdput(bdev); + + free: /* free log descriptor */ kfree(log); jFYI(1, ("lmLogOpen: exit(%d)\n", rc)); @@ -1361,6 +1364,7 @@ */ int lmLogClose(struct super_block *sb, log_t * log) { + struct block_device *bdev = log->bdev; int rc; jFYI(1, ("lmLogClose: log:0x%p\n", log)); @@ -1380,7 +1384,9 @@ externalLog: lmLogFileSystem(log, JFS_SBI(sb)->uuid, 0); rc = lmLogShutdown(log); - blkdev_put(log->bdev, BDEV_FS); + + blkdev_put(bdev, BDEV_FS); + bdput(bdev); out: jFYI(0, ("lmLogClose: exit(%d)\n", rc)); |