[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230818092022.111054-1-mengferry@linux.alibaba.com>
Date: Fri, 18 Aug 2023 17:20:22 +0800
From: Ferry Meng <mengferry@...ux.alibaba.com>
To: Ryusuke Konishi <konishi.ryusuke@...il.com>,
linux-nilfs@...r.kernel.org
Cc: LKML <linux-kernel@...r.kernel.org>,
Ferry Meng <mengferry@...ux.alibaba.com>
Subject: [PATCH] nilfs2: fix dereferencing freed memory
Fix smatch warning:
fs/nilfs2/gcinode.c:103 nilfs_gccache_submit_read_data() error:
dereferencing freed memory 'bh'
Signed-off-by: Ferry Meng <mengferry@...ux.alibaba.com>
diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c
index 48fe71d309cb..6319e825f317 100644
--- a/fs/nilfs2/gcinode.c
+++ b/fs/nilfs2/gcinode.c
@@ -73,10 +73,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
err = nilfs_dat_translate(nilfs->ns_dat, vbn, &pbn);
- if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */
- brelse(bh);
+ if (unlikely(err)) /* -EIO, -ENOMEM, -ENOENT */
goto failed;
- }
}
lock_buffer(bh);
@@ -102,6 +100,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
failed:
unlock_page(bh->b_page);
put_page(bh->b_page);
+ if (err)
+ brelse(bh);
return err;
}
--
2.19.1.6.gb485710b
Powered by blists - more mailing lists