linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] block: remove the write_hint field from struct request
@ 2024-11-14  9:04 Dan Carpenter
  2024-11-14 12:33 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-11-14  9:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block

Hello Christoph Hellwig,

This is a semi-automatic email about new static checker warnings.

Commit 61952bb73486 ("block: remove the write_hint field from struct
request") from Nov 12, 2024, leads to the following Smatch complaint:

block/blk-merge.c:1005 blk_rq_merge_ok() warn: variable dereferenced before check 'rq->bio' (see line 994)

block/blk-merge.c
   993		/* don't merge across cgroup boundaries */
   994		if (!blk_cgroup_mergeable(rq, bio))
                                          ^^
This dereferences rq->bio->

   995			return false;
   996	
   997		/* only merge integrity protected bio into ditto rq */
   998		if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
   999			return false;
  1000	
  1001		/* Only merge if the crypt contexts are compatible */
  1002		if (!bio_crypt_rq_ctx_compatible(rq, bio))
  1003			return false;
  1004	
  1005		if (rq->bio) {
                    ^^^^^^^
So this check shouldn't be required.

  1006			/* Don't merge requests with different write hints. */
  1007			if (rq->bio->bi_write_hint != bio->bi_write_hint)

regards,
dan carpenter

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

* Re: [bug report] block: remove the write_hint field from struct request
  2024-11-14  9:04 [bug report] block: remove the write_hint field from struct request Dan Carpenter
@ 2024-11-14 12:33 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2024-11-14 12:33 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Christoph Hellwig, linux-block

On Thu, Nov 14, 2024 at 12:04:03PM +0300, Dan Carpenter wrote:
>    994		if (!blk_cgroup_mergeable(rq, bio))
>                                           ^^
> This dereferences rq->bio->
> 
>    995			return false;
>    996	
>    997		/* only merge integrity protected bio into ditto rq */
>    998		if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
>    999			return false;
>   1000	
>   1001		/* Only merge if the crypt contexts are compatible */
>   1002		if (!bio_crypt_rq_ctx_compatible(rq, bio))
>   1003			return false;
>   1004	
>   1005		if (rq->bio) {
>                     ^^^^^^^
> So this check shouldn't be required.

Hmm.  The only requests without bios are flush and passthrough
requests.  I guess we make sure they never end up here even if
it is not entirely obvious from the code.


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

end of thread, other threads:[~2024-11-14 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14  9:04 [bug report] block: remove the write_hint field from struct request Dan Carpenter
2024-11-14 12:33 ` Christoph Hellwig

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