Re: [PATCH v2] block: add NULL checks for bic in bfq_bfqq_save_state function
From: Jens Axboe
Date: Wed May 06 2026 - 06:42:04 EST
On 5/6/26 3:04 AM, yanlonglong wrote:
> When the `bic` variable is null, referencing `bfqq_data` through `bic` will
> cause the program to crash. Therefore, the null check for `bic` should be
> moved to the beginning of the function to prevent referencing a null pointer.
Cap at 72 char line length... And title should start with "block, bfq: ".
And should be "add NULL check", singular, see below.
> Fixed:fd571df0ac5b289af8?"block, bfq: turn bfqq_data into an array in bfq_io_cq"?
This tag is wrong, should be a shortened sha and the format is also
wrong (Fixed vs Fixes).
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index 141c602d5e85..e952e4ea2dd4 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -3035,9 +3035,8 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
> static void bfq_bfqq_save_state(struct bfq_queue *bfqq)
> {
> struct bfq_io_cq *bic = bfqq->bic;
> - unsigned int a_idx = bfqq->actuator_idx;
> - struct bfq_iocq_bfqq_data *bfqq_data = &bic->bfqq_data[a_idx];
> -
> + unsigned int a_idx = 0;
> + struct bfq_iocq_bfqq_data *bfqq_data = NULL;
You're killing the empty line between variables and the comment. And why
is a_idx being moved? This is !bic being NULL, presumably?
--
Jens Axboe