From: YueHaibing <yuehaibing@huawei.com>
To: Kent Overstreet <kent.overstreet@gmail.com>
Cc: colyli@suse.de, linux-kernel@vger.kernel.org,
linux-bcache@vger.kernel.org, Yufen Yu <yuyufen@huawei.com>
Subject: Re: [PATCH -next] bcache: Fix potential NULL pointer dereference
Date: Fri, 1 Feb 2019 10:36:44 +0800 [thread overview]
Message-ID: <853cf0ed-330e-8e09-394d-b6a4fc7c5528@huawei.com> (raw)
In-Reply-To: <20190130105817.GA12598@kmo-pixel>
On 2019/1/30 18:58, Kent Overstreet wrote:
> 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.
How about this:
* which would call closure_get(&dc->disk.cl)
*/
ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
+ if (!ddip) {
+ bio->bi_status = BLK_STS_RESOURCE;
+ bio_endio(bio);
+ return;
+ }
ddip->d = d;
ddip->start_time = jiffies;
ddip->bi_end_io = bio->bi_end_io;
>
>
prev parent reply other threads:[~2019-02-01 2:36 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
2019-02-01 2:36 ` YueHaibing [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=853cf0ed-330e-8e09-394d-b6a4fc7c5528@huawei.com \
--to=yuehaibing@huawei.com \
--cc=colyli@suse.de \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yuyufen@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