Эх сурвалжийг харах

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 16 жил өмнө
parent
commit
059ea3318c
1 өөрчлөгдсөн 3 нэмэгдсэн , 1 устгасан
  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;