From: Muthukumar Ratty Date: Wed, 8 Jan 2014 16:39:49 +0000 (-0700) Subject: block: Warn and free bio if bi_end_io is not set X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=95d4403889acbd98e06d41a255df76452210996a;p=linux-beck.git block: Warn and free bio if bi_end_io is not set 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. Signed-off-by: Muthukumar Ratty Signed-off-by: Jens Axboe --- diff --git a/fs/bio.c b/fs/bio.c index 75c49a382239..9156bd1f151c 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -1770,6 +1770,15 @@ void bio_endio(struct bio *bio, int error) } else { if (bio->bi_end_io) bio->bi_end_io(bio, error); + else { + char dev_name[BDEVNAME_SIZE]; + + WARN(1, "bio_endio: bio for %s without endio\n", + bio->bi_bdev ? bdevname(bio->bi_bdev, + dev_name) : "(unknown)"); + bio_put(bio); + } + bio = NULL; } }