public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* Should bio_add_folio() add the folio even it returned false for @len == 0 case?
@ 2026-03-13  2:15 Qu Wenruo
  0 siblings, 0 replies; only message in thread
From: Qu Wenruo @ 2026-03-13  2:15 UTC (permalink / raw)
  To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org

Hi,

Normally no one should call bio_add_folio() with a zero length, but when 
that happened, bio_add_folio() will always return false.

However if the bio has enough free bvec slots, that folio will still be 
added to that folio, breaking that "returning false meaning addition 
failed" assumption.

This can result folio double freeing (well, if you ignore the bigger bug 
of queuing zero length in the first place), as return false normally 
means the add failed, caller normally needs to release that folio manually.

But caller also needs to cleanup that folio, which involves releasing 
each queued folio, resulting double freeing of the last added folio.

Thus I'm wondering if we should add a @len == 0 check (maybe with a 
WARN_ON_ONCE() too) in bio_add_page().

And please don't ask me why/how I hit this, I'm already embarrassed 
enough to hit it in the first place.

Thanks,
Qu

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-13  2:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13  2:15 Should bio_add_folio() add the folio even it returned false for @len == 0 case? Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox