projects/linux·commit 059ea331

block: fix memory leak in bio_clone()

059ea331 · Li Zefan <[email protected]> · 2009-03-09 10:42:45 +01:00

If bio_integrity_clone() fails, bio_clone() returns NULL without freeing
the newly allocated bio.

Signed-off-by: Li Zefan <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Commit
059ea3318c8ede71851a52b4359fbf1ab0cec301
Parents
87092698

Changes

1 files changed · +3 −1

FileStatusAddDelContent
fs/bio.cmodified+3−1View file

fs/bio.c

View file
diff --git a/fs/bio.c b/fs/bio.c
index cf74737..d4f0632 100644
--- 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;