From: Andrey Strachuk <strochuk@ispras.ru>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Andrey Strachuk <strochuk@ispras.ru>,
linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
Subject: [PATCH] efs: removed useless conditional checks in function
Date: Thu, 7 Jul 2022 17:26:52 +0300 [thread overview]
Message-ID: <20220707142652.14447-1-strochuk@ispras.ru> (raw)
At lines 300 and 305, variable "bh" is compared with NULL.
-----------------------------------------------------------
293 exts = (efs_extent *) bh->b_data;
294
295 extent_copy(&(exts[ioffset]), &ext);
296
297 if (ext.cooked.ex_magic != 0) {
298 pr_err("extent %d has bad magic number in block %d\n",
299 cur, iblock);
300 if (bh) brelse(bh);
301 return 0;
302 }
303
304 if ((result = efs_extent_check(&ext, block, sb))) {
305 if (bh) brelse(bh);
306 in->lastextent = cur;
307 return result;
308 }
-----------------------------------------------------------
However, it cannot be NULL because kernel crashes at
line 293 otherwise.
The patch removes useless comparisons.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
fs/efs/inode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index 3ba94bb005a6..a88a0600cdfb 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -297,12 +297,12 @@ efs_block_t efs_map_block(struct inode *inode, efs_block_t block) {
if (ext.cooked.ex_magic != 0) {
pr_err("extent %d has bad magic number in block %d\n",
cur, iblock);
- if (bh) brelse(bh);
+ brelse(bh);
return 0;
}
if ((result = efs_extent_check(&ext, block, sb))) {
- if (bh) brelse(bh);
+ brelse(bh);
in->lastextent = cur;
return result;
}
--
2.25.1
next reply other threads:[~2022-07-07 14:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 14:26 Andrey Strachuk [this message]
2022-07-07 14:34 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220707142652.14447-1-strochuk@ispras.ru \
--to=strochuk@ispras.ru \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®