aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJoern Engel <joern@logfs.org>2010-04-15 02:03:57 -0400
committerJoern Engel <joern@logfs.org>2010-04-15 02:03:57 -0400
commit1f1b0008e8dd1930d6e89522c70f4a438374302a (patch)
treefb35404bdb4db79925891779e3be118eca8e85dd /fs
parentead88af5f577fd2b399a0fcdfe52605116fac489 (diff)
[LogFS] Prevent mempool_destroy NULL pointer dereference
It would probably be better to just accept NULL pointers in mempool_destroy(). But for the current -rc series let's keep things simple. This patch was lost in the cracks for a while. Kevin Cernekee <cernekee@gmail.com> had to rediscover the problem and send a similar patch because of it. :( Signed-off-by: Joern Engel <joern@logfs.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/logfs/logfs.h6
-rw-r--r--fs/logfs/readwrite.c6
-rw-r--r--fs/logfs/segment.c2
-rw-r--r--fs/logfs/super.c4
4 files changed, 11 insertions, 7 deletions
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index c9929eed80b1..0a3df1a0c936 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -727,4 +727,10 @@ static inline struct logfs_area *get_area(struct super_block *sb,
727 return logfs_super(sb)->s_area[(__force u8)gc_level]; 727 return logfs_super(sb)->s_area[(__force u8)gc_level];
728} 728}
729 729
730static inline void logfs_mempool_destroy(mempool_t *pool)
731{
732 if (pool)
733 mempool_destroy(pool);
734}
735
730#endif 736#endif
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
index 7e0c39c49719..aca6c56a107a 100644
--- a/fs/logfs/readwrite.c
+++ b/fs/logfs/readwrite.c
@@ -2243,8 +2243,6 @@ void logfs_cleanup_rw(struct super_block *sb)
2243 struct logfs_super *super = logfs_super(sb); 2243 struct logfs_super *super = logfs_super(sb);
2244 2244
2245 destroy_meta_inode(super->s_segfile_inode); 2245 destroy_meta_inode(super->s_segfile_inode);
2246 if (super->s_block_pool) 2246 logfs_mempool_destroy(super->s_block_pool);
2247 mempool_destroy(super->s_block_pool); 2247 logfs_mempool_destroy(super->s_shadow_pool);
2248 if (super->s_shadow_pool)
2249 mempool_destroy(super->s_shadow_pool);
2250} 2248}
diff --git a/fs/logfs/segment.c b/fs/logfs/segment.c
index 02db22ebbf13..8c82fe05d3e1 100644
--- a/fs/logfs/segment.c
+++ b/fs/logfs/segment.c
@@ -912,7 +912,7 @@ err:
912 for (i--; i >= 0; i--) 912 for (i--; i >= 0; i--)
913 free_area(super->s_area[i]); 913 free_area(super->s_area[i]);
914 free_area(super->s_journal_area); 914 free_area(super->s_journal_area);
915 mempool_destroy(super->s_alias_pool); 915 logfs_mempool_destroy(super->s_alias_pool);
916 return -ENOMEM; 916 return -ENOMEM;
917} 917}
918 918
diff --git a/fs/logfs/super.c b/fs/logfs/super.c
index d6e1f4fc3115..d4531eb46d0a 100644
--- a/fs/logfs/super.c
+++ b/fs/logfs/super.c
@@ -517,8 +517,8 @@ static void logfs_kill_sb(struct super_block *sb)
517 if (super->s_erase_page) 517 if (super->s_erase_page)
518 __free_page(super->s_erase_page); 518 __free_page(super->s_erase_page);
519 super->s_devops->put_device(sb); 519 super->s_devops->put_device(sb);
520 mempool_destroy(super->s_btree_pool); 520 logfs_mempool_destroy(super->s_btree_pool);
521 mempool_destroy(super->s_alias_pool); 521 logfs_mempool_destroy(super->s_alias_pool);
522 kfree(super); 522 kfree(super);
523 log_super("LogFS: Finished unmounting\n"); 523 log_super("LogFS: Finished unmounting\n");
524} 524}