When memory is low and the allocation for 'dip->csums' fail in 
fs/btrfs/inode.c:btrfs_submit_direct() we make the situation worse by 
leaking the memory allocated to 'dip'.
This patch removes the leak by kfree()'ing 'dip' before jumping to the 
'free_ordered' label.

Signed-off-by: Jesper Juhl <j...@chaosbits.net>
---
 inode.c |    1 +
 1 file changed, 1 insertion(+)

 compile tested only.

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0efdb65..53f4c8e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6056,6 +6056,7 @@ static void btrfs_submit_direct(int rw, struct bio *bio, 
struct inode *inode,
        if (!skip_sum) {
                dip->csums = kmalloc(sizeof(u32) * bio->bi_vcnt, GFP_NOFS);
                if (!dip->csums) {
+                       kfree(dip);
                        ret = -ENOMEM;
                        goto free_ordered;
                }


-- 
Jesper Juhl <j...@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to