linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] omfs: Fix a memory leak bug
@ 2019-08-20  6:22 Wenwen Wang
  2019-08-20 14:16 ` Bob Copeland
  0 siblings, 1 reply; 2+ messages in thread
From: Wenwen Wang @ 2019-08-20  6:22 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: Bob Copeland, open list:OMFS FILESYSTEM, open list

In omfs_get_imap(), 'sbi->s_imap' is allocated through kcalloc(). However,
it is not deallocated in the following execution if 'block' is not less
than 'sbi->s_num_blocks', leading to a memory leak bug. To fix this issue,
go to the 'nomem_free' label to free 'sbi->s_imap'.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 fs/omfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 08226a8..e4d89a6 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -356,7 +356,7 @@ static int omfs_get_imap(struct super_block *sb)
 
 	block = clus_to_blk(sbi, sbi->s_bitmap_ino);
 	if (block >= sbi->s_num_blocks)
-		goto nomem;
+		goto nomem_free;
 
 	ptr = sbi->s_imap;
 	for (count = bitmap_size; count > 0; count -= sb->s_blocksize) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] omfs: Fix a memory leak bug
  2019-08-20  6:22 [PATCH] omfs: Fix a memory leak bug Wenwen Wang
@ 2019-08-20 14:16 ` Bob Copeland
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Copeland @ 2019-08-20 14:16 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: open list:OMFS FILESYSTEM, open list

On Tue, Aug 20, 2019 at 01:22:59AM -0500, Wenwen Wang wrote:
> In omfs_get_imap(), 'sbi->s_imap' is allocated through kcalloc(). However,
> it is not deallocated in the following execution if 'block' is not less
> than 'sbi->s_num_blocks', leading to a memory leak bug. To fix this issue,
> go to the 'nomem_free' label to free 'sbi->s_imap'.

Nice catch, thanks.

Acked-by: Bob Copeland <me@bobcopeland.com>

-- 
Bob Copeland %% https://bobcopeland.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-20 14:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20  6:22 [PATCH] omfs: Fix a memory leak bug Wenwen Wang
2019-08-20 14:16 ` Bob Copeland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).