]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] bio: fix leak in failure case in bio_copy_user()
authorJens Axboe <axboe@suse.de>
Fri, 26 Nov 2004 01:08:06 +0000 (17:08 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 26 Nov 2004 01:08:06 +0000 (17:08 -0800)
There's a leak in the error case in bio_copy_user().  If we fail
allocating a page or adding a page to the bio, we will leak the bio map
data.

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/bio.c

index 0ebd86b4ad9f6f6008867b3a424e2e60a4bb60b3..932266e3fd3bce2bd91ea45d61fc9d00c05382e2 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -461,11 +461,10 @@ struct bio *bio_copy_user(request_queue_t *q, unsigned long uaddr,
 
        bmd->userptr = (void __user *) uaddr;
 
+       ret = -ENOMEM;
        bio = bio_alloc(GFP_KERNEL, end - start);
-       if (!bio) {
-               bio_free_map_data(bmd);
-               return ERR_PTR(-ENOMEM);
-       }
+       if (!bio)
+               goto out_bmd;
 
        bio->bi_rw |= (!write_to_vm << BIO_RW);
 
@@ -519,6 +518,8 @@ cleanup:
                __free_page(bvec->bv_page);
 
        bio_put(bio);
+out_bmd:
+       bio_free_map_data(bmd);
        return ERR_PTR(ret);
 }