From: Ryusuke Konishi Date: Wed, 8 May 2024 22:14:29 +0000 (+0900) Subject: nilfs2: convert BUG_ON() in nilfs_finish_roll_forward() to WARN_ON() X-Git-Tag: nvme-6.10-2024-06-05~117^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0a73eac1ed10097d1799c10dff2172605fd40c75;p=nvme.git nilfs2: convert BUG_ON() in nilfs_finish_roll_forward() to WARN_ON() The BUG_ON check performed on the return value of __getblk() in nilfs_finish_roll_forward() assumes that a buffer that has been successfully read once is retrieved with the same parameters and does not fail (__getblk() does not return an error due to memory allocation failure). Also, nilfs_finish_roll_forward() is called at most once during mount. Taking these into consideration, rewrite the check to use WARN_ON() to avoid using BUG_ON(). Link: https://lkml.kernel.org/r/20240508221429.7559-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Signed-off-by: Andrew Morton --- diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c index e48372618ac4..020f304c600e 100644 --- a/fs/nilfs2/recovery.c +++ b/fs/nilfs2/recovery.c @@ -699,7 +699,9 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, return; bh = __getblk(nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize); - BUG_ON(!bh); + if (WARN_ON(!bh)) + return; /* should never happen */ + memset(bh->b_data, 0, bh->b_size); set_buffer_dirty(bh); err = sync_dirty_buffer(bh);