fs/bio-integrity: fix a potential mem leak
authorGu Zheng <guz.fnst@cn.fujitsu.com>
Wed, 11 Sep 2013 21:23:21 +0000 (14:23 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Sep 2013 22:58:21 +0000 (15:58 -0700)
Free the bio_integrity_pool in the fail path of biovec_create_pool in
function bioset_integrity_create().

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/bio-integrity.c

index 8fb42916d8a29812e349fdbfa980ef1c34056ce4..60250847929fcd0421e5d72b9655bbe4c3a785e1 100644 (file)
@@ -716,13 +716,14 @@ int bioset_integrity_create(struct bio_set *bs, int pool_size)
                return 0;
 
        bs->bio_integrity_pool = mempool_create_slab_pool(pool_size, bip_slab);
-
-       bs->bvec_integrity_pool = biovec_create_pool(bs, pool_size);
-       if (!bs->bvec_integrity_pool)
+       if (!bs->bio_integrity_pool)
                return -1;
 
-       if (!bs->bio_integrity_pool)
+       bs->bvec_integrity_pool = biovec_create_pool(bs, pool_size);
+       if (!bs->bvec_integrity_pool) {
+               mempool_destroy(bs->bio_integrity_pool);
                return -1;
+       }
 
        return 0;
 }