public inbox for linux-bcache@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@gmail.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: colyli@suse.de, linux-kernel@vger.kernel.org,
	linux-bcache@vger.kernel.org
Subject: Re: [PATCH -next] bcache: Fix potential NULL pointer dereference
Date: Wed, 30 Jan 2019 05:58:17 -0500	[thread overview]
Message-ID: <20190130105817.GA12598@kmo-pixel> (raw)
In-Reply-To: <20190130102112.11228-1-yuehaibing@huawei.com>

On Wed, Jan 30, 2019 at 06:21:12PM +0800, YueHaibing wrote:
> There is a potential NULL pointer dereference in case
> kzalloc() fails and returns NULL.
> 
> Fixes: bc082a55d25c ("bcache: fix inaccurate io state for detached bcache devices")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/md/bcache/request.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index 1507041..a50afa4 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1094,6 +1094,8 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio)
>  	 * which would call closure_get(&dc->disk.cl)
>  	 */
>  	ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
> +	if (!ddip)
> +		return;
>  	ddip->d = d;
>  	ddip->start_time = jiffies;
>  	ddip->bi_end_io = bio->bi_end_io;

This should be using a mempool/bioset... just returning from a make_request
function is not correct, that's a serious bug - you're just dropping an IO on
the floor, which is going to cause whatever submitted that IO to hang.

  reply	other threads:[~2019-01-30 10:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 10:21 [PATCH -next] bcache: Fix potential NULL pointer dereference YueHaibing
2019-01-30 10:58 ` Kent Overstreet [this message]
2019-02-01  2:36   ` YueHaibing

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=20190130105817.GA12598@kmo-pixel \
    --to=kent.overstreet@gmail.com \
    --cc=colyli@suse.de \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuehaibing@huawei.com \
    /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