* [block:for-3.14/core]: bio_endio: Warn and free bio if bi_end_io is not set.
@ 2014-01-08 1:57 Muthu Kumar
2014-01-08 16:34 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Muthu Kumar @ 2014-01-08 1:57 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Jens,
In bio_endio if bio doesn't have bi_end_io (should be an error case),
we set bio to NULL and continue silently without freeing the bio. It
would be good to have a WARN and free the bio to avoid memory leak.
If you agree, here is the patch.
---------
bio_endio: Warn and free bio if bi_end_io is not set
Signed-off-by: Muthukumar Ratty <muthur@gmail.com>
--------
fs/bio.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/bio.c b/fs/bio.c
index 75c49a3..581806d 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1768,8 +1768,15 @@ void bio_endio(struct bio *bio, int error)
bio_put(bio);
bio = parent;
} else {
- if (bio->bi_end_io)
+ if (likely(bio->bi_end_io)) {
bio->bi_end_io(bio, error);
+ } else {
+ char dev_name[BDEVNAME_SIZE];
+ WARN(1, "bio_endio: bio for device %s without endio\n",
+ bio->bi_bdev ? bdevname(bio->bi_bdev,
dev_name) : "(unknown)");
+ bio_put(bio);
+ }
+
bio = NULL;
}
}
---------------
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [block:for-3.14/core]: bio_endio: Warn and free bio if bi_end_io is not set.
2014-01-08 1:57 [block:for-3.14/core]: bio_endio: Warn and free bio if bi_end_io is not set Muthu Kumar
@ 2014-01-08 16:34 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2014-01-08 16:34 UTC (permalink / raw)
To: Muthu Kumar, linux-kernel
On 01/07/2014 06:57 PM, Muthu Kumar wrote:
> Jens,
> In bio_endio if bio doesn't have bi_end_io (should be an error case),
> we set bio to NULL and continue silently without freeing the bio. It
> would be good to have a WARN and free the bio to avoid memory leak.
>
> If you agree, here is the patch.
I don't remember off the top of my head if there are valid uses cases of
it. But leaking it would definitely be problematic. So I think it's a
good idea to queue it up, then we'll see if it triggers anything.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-08 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-08 1:57 [block:for-3.14/core]: bio_endio: Warn and free bio if bi_end_io is not set Muthu Kumar
2014-01-08 16:34 ` 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.