* [PATCH -next] bcache: Fix potential NULL pointer dereference
@ 2019-01-30 10:21 YueHaibing
2019-01-30 10:58 ` Kent Overstreet
0 siblings, 1 reply; 3+ messages in thread
From: YueHaibing @ 2019-01-30 10:21 UTC (permalink / raw)
To: colyli, kent.overstreet; +Cc: linux-kernel, linux-bcache, YueHaibing
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;
--
2.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] bcache: Fix potential NULL pointer dereference
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
0 siblings, 1 reply; 3+ messages in thread
From: Kent Overstreet @ 2019-01-30 10:58 UTC (permalink / raw)
To: YueHaibing; +Cc: colyli, linux-kernel, linux-bcache
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] bcache: Fix potential NULL pointer dereference
2019-01-30 10:58 ` Kent Overstreet
@ 2019-02-01 2:36 ` YueHaibing
0 siblings, 0 replies; 3+ messages in thread
From: YueHaibing @ 2019-02-01 2:36 UTC (permalink / raw)
To: Kent Overstreet; +Cc: colyli, linux-kernel, linux-bcache, Yufen Yu
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;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-01 2:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).