block/blk-merge.c:1006 blk_rq_merge_ok() warn: variable dereferenced before check 'rq->bio' (see line 995)
PATCH 2/2 block/blk-merge.c:1006 blk_rq_merge_ok() warn: variable dereferenced before check 'rq->bio' (see line 995)
tree: https://android.googlesource.com/kernel/common android-mainline head: 41a0b7bfea10dffbd255cc0978b755dc0f427832 commit: 61952bb73486fff0f5550bccdf4062d9dd0fb163 [2/2] block: remove the write_hint field from struct request config: i386-randconfig-141-20250305 (https://download.01.org/0day-ci/archive/20250305/[email protected]/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:block/blk-merge.c:1006 blk_rq_merge_ok() warn: variable dereferenced before check 'rq->bio' (see line 995)
vim +1006 block/blk-merge.c
050c8ea80e3e90 Tejun Heo 2012-02-08 982 bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
050c8ea80e3e90 Tejun Heo 2012-02-08 983 {
e2a60da74fc821 Martin K. Petersen 2012-09-18 984 if (!rq_mergeable(rq) || !bio_mergeable(bio))
050c8ea80e3e90 Tejun Heo 2012-02-08 985 return false;
050c8ea80e3e90 Tejun Heo 2012-02-08 986
288dab8a35a0bd Christoph Hellwig 2016-06-09 987 if (req_op(rq) != bio_op(bio))
f31dc1cd490539 Martin K. Petersen 2012-09-18 988 return false;
f31dc1cd490539 Martin K. Petersen 2012-09-18 989
050c8ea80e3e90 Tejun Heo 2012-02-08 990 /* different data direction or already started, don't merge */
050c8ea80e3e90 Tejun Heo 2012-02-08 991 if (bio_data_dir(bio) != rq_data_dir(rq))
050c8ea80e3e90 Tejun Heo 2012-02-08 992 return false;
050c8ea80e3e90 Tejun Heo 2012-02-08 993
6b2b04590b51aa Tejun Heo 2022-03-14 994 /* don't merge across cgroup boundaries */6b2b04590b51aa Tejun Heo 2022-03-14 @995 if (!blk_cgroup_mergeable(rq, bio))
rq->bio dereferenced inside the function.
6b2b04590b51aa Tejun Heo 2022-03-14 996 return false;
6b2b04590b51aa Tejun Heo 2022-03-14 997
050c8ea80e3e90 Tejun Heo 2012-02-08 998 /* only merge integrity protected bio into ditto rq */
4eaf99beadcefb Martin K. Petersen 2014-09-26 999 if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
050c8ea80e3e90 Tejun Heo 2012-02-08 1000 return false;
050c8ea80e3e90 Tejun Heo 2012-02-08 1001
a892c8d52c0228 Satya Tangirala 2020-05-14 1002 /* Only merge if the crypt contexts are compatible */
a892c8d52c0228 Satya Tangirala 2020-05-14 1003 if (!bio_crypt_rq_ctx_compatible(rq, bio))
a892c8d52c0228 Satya Tangirala 2020-05-14 1004 return false;
a892c8d52c0228 Satya Tangirala 2020-05-14 1005
61952bb73486ff Christoph Hellwig 2024-11-12 @1006 if (rq->bio) {Checked too late
449813515d3e5e Bart Van Assche 2024-02-02 1007 /* Don't merge requests with different write hints. */ 61952bb73486ff Christoph Hellwig 2024-11-12 1008 if (rq->bio->bi_write_hint != bio->bi_write_hint) 449813515d3e5e Bart Van Assche 2024-02-02 1009 return false; 61952bb73486ff Christoph Hellwig 2024-11-12 1010 } 449813515d3e5e Bart Van Assche 2024-02-02 1011 668ffc03418bc7 Damien Le Moal 2018-11-20 1012 if (rq->ioprio != bio_prio(bio)) 668ffc03418bc7 Damien Le Moal 2018-11-20 1013 return false; 668ffc03418bc7 Damien Le Moal 2018-11-20 1014 9da3d1e912f395 John Garry 2024-06-20 1015 if (blk_atomic_write_mergeable_rq_bio(rq, bio) == false) 9da3d1e912f395 John Garry 2024-06-20 1016 return false; 9da3d1e912f395 John Garry 2024-06-20 1017 050c8ea80e3e90 Tejun Heo 2012-02-08 1018 return true; 050c8ea80e3e90 Tejun Heo 2012-02-08 1019 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki