block: fix memory leak in bio_clone()
authorLi Zefan <lizf@cn.fujitsu.com>
Mon, 9 Mar 2009 09:42:45 +0000 (10:42 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Sat, 14 Mar 2009 20:06:52 +0000 (21:06 +0100)
If bio_integrity_clone() fails, bio_clone() returns NULL without freeing
the newly allocated bio.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fs/bio.c

index cf747378b97773725ca077213b93bb6c2acb641a..d4f06327c810b163e2165455f6c0466c98b42f25 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -465,8 +465,10 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
 
                ret = bio_integrity_clone(b, bio, gfp_mask, fs_bio_set);
 
-               if (ret < 0)
+               if (ret < 0) {
+                       bio_put(b);
                        return NULL;
+               }
        }
 
        return b;