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 <mut...@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;
         }
     }

---------------
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to