All of lore.kernel.org
 help / color / mirror / Atom feed
* Possible bug in block/bounce.c
@ 2020-07-15 15:50 Ziyang Li
  2020-07-15 15:59 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Ziyang Li @ 2020-07-15 15:50 UTC (permalink / raw)
  To: axboe, linux-block

Hi all:

I hope this is the right place to ask about a potential bug in bounce.c. So on line 329 we assign the result of `mempool_alloc` to `to->bv_page` but we never check if `to->bv_page` is a valid pointer, also given that this variable is dereferenced in inc_zone_page_state. I wonder if we should add something like `if (to->bv_page == null)` here?

329: to->bv_page = mempool_alloc(pool, q->bounce_gfp);
330: inc_zone_page_state(to->bv_page, NR_BOUNCE);

Best,
Ziyang

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Possible bug in block/bounce.c
  2020-07-15 15:50 Possible bug in block/bounce.c Ziyang Li
@ 2020-07-15 15:59 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-07-15 15:59 UTC (permalink / raw)
  To: Ziyang Li, linux-block

On 7/15/20 9:50 AM, Ziyang Li wrote:
> Hi all:
> 
> I hope this is the right place to ask about a potential bug in
> bounce.c. So on line 329 we assign the result of `mempool_alloc` to
> `to->bv_page` but we never check if `to->bv_page` is a valid pointer,
> also given that this variable is dereferenced in inc_zone_page_state.
> I wonder if we should add something like `if (to->bv_page == null)`
> here?
> 
> 329: to->bv_page = mempool_alloc(pool, q->bounce_gfp);
> 330: inc_zone_page_state(to->bv_page, NR_BOUNCE);

bounce_gfp must have __GFP_WAIT set, which guarantees that
mempool_alloc() will always (eventually) return an allocation
successfully.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-15 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 15:50 Possible bug in block/bounce.c Ziyang Li
2020-07-15 15:59 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.