Explorar o código

block: fix memory leak in bio_clone()

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>
Li Zefan %!s(int64=16) %!d(string=hai) anos
pai
achega
059ea3318c
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      fs/bio.c

+ 3 - 1
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;