mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] efs: removed useless conditional checks in function
@ 2022-07-07 14:26 Andrey Strachuk
  2022-07-07 14:34 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Strachuk @ 2022-07-07 14:26 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Andrey Strachuk, linux-kernel, ldv-project

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


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

* Re: [PATCH] efs: removed useless conditional checks in function
  2022-07-07 14:26 [PATCH] efs: removed useless conditional checks in function Andrey Strachuk
@ 2022-07-07 14:34 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2022-07-07 14:34 UTC (permalink / raw)
  To: Andrey Strachuk; +Cc: linux-kernel, ldv-project, linux-fsdevel

On Thu, Jul 07, 2022 at 05:26:52PM +0300, Andrey Strachuk wrote:
> However, it cannot be NULL because kernel crashes at
> line 293 otherwise.
> The patch removes useless comparisons.

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Not sure who's going to merge this patch.  I guess I can throw it into
the pagecache tree if nobody else wants it.

> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

If you really want to be fancy, you can delve into linux-fullhistory and
come up with:

Fixes: 2b50c6738b500 ("Import 2.3.2")

although I bet that breaks a few scripts.

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

end of thread, other threads:[~2022-07-07 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 14:26 [PATCH] efs: removed useless conditional checks in function Andrey Strachuk
2022-07-07 14:34 ` Matthew Wilcox

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®