linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: remove unnecessary NULL check
@ 2022-01-28 14:09 Dan Carpenter
  2022-02-02 14:12 ` Christoph Hellwig
  2022-02-02 14:51 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-01-28 14:09 UTC (permalink / raw)
  To: Konstantin Komarov, Christoph Hellwig, Jens Axboe
  Cc: ntfs3, linux-kernel, linux-block, kernel-janitors

This code triggers a Smatch warning:

    fs/ntfs3/fsntfs.c:1606 ntfs_bio_fill_1()
    warn: variable dereferenced before check 'bio' (see line 1591)

The "bio" pointer cannot be NULL so there is no need to check.
Originally there was more extensive NULL checking but it was removed
because bio_alloc() will never fail if it is allowed to sleep.

Remove this check as well.

Fixes: 087b2fb84908 ("ntfs3: remove ntfs_alloc_bio")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This patch applies on top of Christoph's bio allocation series and needs
through the block tree, I think.  I included a Fixes tag even though
it's not really a bugfix...

 fs/ntfs3/fsntfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index 0660a07c5a96..3de5700a9b83 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -1603,11 +1603,10 @@ int ntfs_bio_fill_1(struct ntfs_sb_info *sbi, const struct runs_tree *run)
 		}
 	} while (run_get_entry(run, ++run_idx, NULL, &lcn, &clen));
 
-	if (bio) {
-		if (!err)
-			err = submit_bio_wait(bio);
-		bio_put(bio);
-	}
+	if (!err)
+		err = submit_bio_wait(bio);
+	bio_put(bio);
+
 	blk_finish_plug(&plug);
 out:
 	unlock_page(fill);
-- 
2.20.1


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

* Re: [PATCH] fs/ntfs3: remove unnecessary NULL check
  2022-01-28 14:09 [PATCH] fs/ntfs3: remove unnecessary NULL check Dan Carpenter
@ 2022-02-02 14:12 ` Christoph Hellwig
  2022-02-02 14:51 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-02-02 14:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Konstantin Komarov, Christoph Hellwig, Jens Axboe, ntfs3,
	linux-kernel, linux-block, kernel-janitors

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH] fs/ntfs3: remove unnecessary NULL check
  2022-01-28 14:09 [PATCH] fs/ntfs3: remove unnecessary NULL check Dan Carpenter
  2022-02-02 14:12 ` Christoph Hellwig
@ 2022-02-02 14:51 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2022-02-02 14:51 UTC (permalink / raw)
  To: Christoph Hellwig, Dan Carpenter, Konstantin Komarov
  Cc: ntfs3, linux-block, linux-kernel, kernel-janitors

On Fri, 28 Jan 2022 17:09:22 +0300, Dan Carpenter wrote:
> This code triggers a Smatch warning:
> 
>     fs/ntfs3/fsntfs.c:1606 ntfs_bio_fill_1()
>     warn: variable dereferenced before check 'bio' (see line 1591)
> 
> The "bio" pointer cannot be NULL so there is no need to check.
> Originally there was more extensive NULL checking but it was removed
> because bio_alloc() will never fail if it is allowed to sleep.
> 
> [...]

Applied, thanks!

[1/1] fs/ntfs3: remove unnecessary NULL check
      commit: 365ab499153cdb2007d54e7e62bcbf2c67f7ab8f

Best regards,
-- 
Jens Axboe



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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 14:09 [PATCH] fs/ntfs3: remove unnecessary NULL check Dan Carpenter
2022-02-02 14:12 ` Christoph Hellwig
2022-02-02 14:51 ` Jens Axboe

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).