mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
	kent.overstreet@gmail.com
Subject: Re: [PATCH] md: bcache: check the return value of mempool_alloc() in bch_btree_node_read_done()
Date: Wed, 2 Mar 2022 18:29:15 +0800	[thread overview]
Message-ID: <0130200c-bbb1-9d7f-e177-6ffbc60db405@suse.de> (raw)
In-Reply-To: <20220225082804.19793-1-baijiaju1990@gmail.com>

On 2/25/22 4:28 PM, Jia-Ju Bai wrote:
> The function mempool_alloc() in bch_btree_node_read_done() can fail, so
> its return value should be checked.
>
> Fixes: d19936a26658 ("bcache: convert to bioset_init()/mempool_init()")
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>   drivers/md/bcache/btree.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> index 88c573eeb598..fb8b7dd6bcc2 100644
> --- a/drivers/md/bcache/btree.c
> +++ b/drivers/md/bcache/btree.c
> @@ -157,6 +157,8 @@ void bch_btree_node_read_done(struct btree *b)
>   	 * See the comment arount cache_set->fill_iter.
>   	 */
>   	iter = mempool_alloc(&b->c->fill_iter, GFP_NOIO);
> +	if (!iter)
> +		return;


This is unnecessary, mempool_alloc() doesn't return NULL in this condition.


Coly Li



>   	iter->size = b->c->cache->sb.bucket_size / b->c->cache->sb.block_size;
>   	iter->used = 0;
>   



      reply	other threads:[~2022-03-02 10:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25  8:28 Jia-Ju Bai
2022-03-02 10:29 ` Coly Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0130200c-bbb1-9d7f-e177-6ffbc60db405@suse.de \
    --to=colyli@suse.de \
    --cc=baijiaju1990@gmail.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®