diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-07-26 04:06:00 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-10-29 04:16:48 -0400 |
commit | e5a0726a953daf224ae42bcf5edaa64f71b4e8a7 (patch) | |
tree | 0f0be6f8e0b2324b5e29ac959837ab470afa0053 /fs/logfs | |
parent | 7d945a3aa7608f68dba04083d3421e0b43052660 (diff) |
logfs: fix a leak in get_sb
a) switch ->put_device() to logfs_super *
b) actually call it on early failures in logfs_get_sb_device()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/logfs')
-rw-r--r-- | fs/logfs/dev_bdev.c | 4 | ||||
-rw-r--r-- | fs/logfs/dev_mtd.c | 4 | ||||
-rw-r--r-- | fs/logfs/logfs.h | 3 | ||||
-rw-r--r-- | fs/logfs/super.c | 4 |
4 files changed, 8 insertions, 7 deletions
diff --git a/fs/logfs/dev_bdev.c b/fs/logfs/dev_bdev.c index 223b673dcc7b..92ca6fbe09bd 100644 --- a/fs/logfs/dev_bdev.c +++ b/fs/logfs/dev_bdev.c | |||
@@ -298,9 +298,9 @@ static int bdev_write_sb(struct super_block *sb, struct page *page) | |||
298 | return sync_request(page, bdev, WRITE); | 298 | return sync_request(page, bdev, WRITE); |
299 | } | 299 | } |
300 | 300 | ||
301 | static void bdev_put_device(struct super_block *sb) | 301 | static void bdev_put_device(struct logfs_super *s) |
302 | { | 302 | { |
303 | close_bdev_exclusive(logfs_super(sb)->s_bdev, FMODE_READ|FMODE_WRITE); | 303 | close_bdev_exclusive(s->s_bdev, FMODE_READ|FMODE_WRITE); |
304 | } | 304 | } |
305 | 305 | ||
306 | static int bdev_can_write_buf(struct super_block *sb, u64 ofs) | 306 | static int bdev_can_write_buf(struct super_block *sb, u64 ofs) |
diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c index 9e3dbe3712ae..7466e9dcc8c5 100644 --- a/fs/logfs/dev_mtd.c +++ b/fs/logfs/dev_mtd.c | |||
@@ -230,9 +230,9 @@ static void mtd_writeseg(struct super_block *sb, u64 ofs, size_t len) | |||
230 | __mtd_writeseg(sb, ofs, ofs >> PAGE_SHIFT, len >> PAGE_SHIFT); | 230 | __mtd_writeseg(sb, ofs, ofs >> PAGE_SHIFT, len >> PAGE_SHIFT); |
231 | } | 231 | } |
232 | 232 | ||
233 | static void mtd_put_device(struct super_block *sb) | 233 | static void mtd_put_device(struct logfs_super *s) |
234 | { | 234 | { |
235 | put_mtd_device(logfs_super(sb)->s_mtd); | 235 | put_mtd_device(s->s_mtd); |
236 | } | 236 | } |
237 | 237 | ||
238 | static int mtd_can_write_buf(struct super_block *sb, u64 ofs) | 238 | static int mtd_can_write_buf(struct super_block *sb, u64 ofs) |
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h index 5d2e66b48290..446c0f12d899 100644 --- a/fs/logfs/logfs.h +++ b/fs/logfs/logfs.h | |||
@@ -136,6 +136,7 @@ struct logfs_area_ops { | |||
136 | int (*erase_segment)(struct logfs_area *area); | 136 | int (*erase_segment)(struct logfs_area *area); |
137 | }; | 137 | }; |
138 | 138 | ||
139 | struct logfs_super; /* forward */ | ||
139 | /** | 140 | /** |
140 | * struct logfs_device_ops - device access operations | 141 | * struct logfs_device_ops - device access operations |
141 | * | 142 | * |
@@ -156,7 +157,7 @@ struct logfs_device_ops { | |||
156 | int ensure_write); | 157 | int ensure_write); |
157 | int (*can_write_buf)(struct super_block *sb, u64 ofs); | 158 | int (*can_write_buf)(struct super_block *sb, u64 ofs); |
158 | void (*sync)(struct super_block *sb); | 159 | void (*sync)(struct super_block *sb); |
159 | void (*put_device)(struct super_block *sb); | 160 | void (*put_device)(struct logfs_super *s); |
160 | }; | 161 | }; |
161 | 162 | ||
162 | /** | 163 | /** |
diff --git a/fs/logfs/super.c b/fs/logfs/super.c index f57a150b4779..f07d40e41c3f 100644 --- a/fs/logfs/super.c +++ b/fs/logfs/super.c | |||
@@ -529,7 +529,7 @@ static void logfs_kill_sb(struct super_block *sb) | |||
529 | logfs_cleanup_rw(sb); | 529 | logfs_cleanup_rw(sb); |
530 | if (super->s_erase_page) | 530 | if (super->s_erase_page) |
531 | __free_page(super->s_erase_page); | 531 | __free_page(super->s_erase_page); |
532 | super->s_devops->put_device(sb); | 532 | super->s_devops->put_device(super); |
533 | logfs_mempool_destroy(super->s_btree_pool); | 533 | logfs_mempool_destroy(super->s_btree_pool); |
534 | logfs_mempool_destroy(super->s_alias_pool); | 534 | logfs_mempool_destroy(super->s_alias_pool); |
535 | kfree(super); | 535 | kfree(super); |
@@ -586,8 +586,8 @@ err1: | |||
586 | deactivate_locked_super(sb); | 586 | deactivate_locked_super(sb); |
587 | return err; | 587 | return err; |
588 | err0: | 588 | err0: |
589 | super->s_devops->put_device(super); | ||
589 | kfree(super); | 590 | kfree(super); |
590 | //devops->put_device(sb); | ||
591 | return err; | 591 | return err; |
592 | } | 592 | } |
593 | 593 | ||