Commit 1f1b0008e8dd1930d6e89522c70f4a438374302a

Authored by Joern Engel
1 parent ead88af5f5

[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>

Showing 4 changed files with 11 additions and 7 deletions Side-by-side Diff

... ... @@ -727,5 +727,11 @@
727 727 return logfs_super(sb)->s_area[(__force u8)gc_level];
728 728 }
729 729  
  730 +static inline void logfs_mempool_destroy(mempool_t *pool)
  731 +{
  732 + if (pool)
  733 + mempool_destroy(pool);
  734 +}
  735 +
730 736 #endif
fs/logfs/readwrite.c
... ... @@ -2243,9 +2243,7 @@
2243 2243 struct logfs_super *super = logfs_super(sb);
2244 2244  
2245 2245 destroy_meta_inode(super->s_segfile_inode);
2246   - if (super->s_block_pool)
2247   - mempool_destroy(super->s_block_pool);
2248   - if (super->s_shadow_pool)
2249   - mempool_destroy(super->s_shadow_pool);
  2246 + logfs_mempool_destroy(super->s_block_pool);
  2247 + logfs_mempool_destroy(super->s_shadow_pool);
2250 2248 }
... ... @@ -912,7 +912,7 @@
912 912 for (i--; i >= 0; i--)
913 913 free_area(super->s_area[i]);
914 914 free_area(super->s_journal_area);
915   - mempool_destroy(super->s_alias_pool);
  915 + logfs_mempool_destroy(super->s_alias_pool);
916 916 return -ENOMEM;
917 917 }
918 918  
... ... @@ -517,8 +517,8 @@
517 517 if (super->s_erase_page)
518 518 __free_page(super->s_erase_page);
519 519 super->s_devops->put_device(sb);
520   - mempool_destroy(super->s_btree_pool);
521   - mempool_destroy(super->s_alias_pool);
  520 + logfs_mempool_destroy(super->s_btree_pool);
  521 + logfs_mempool_destroy(super->s_alias_pool);
522 522 kfree(super);
523 523 log_super("LogFS: Finished unmounting\n");
524 524 }