[PATCH] memory leakage in ext4_ext_zeroout

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: jing zhang
Date: Friday, March 12, 2010 - 11:33 pm

From: Jing Zhang <zj.barak@gmail.com>

Date: Sat Mar 13 14:05:27     2010

When EIO occurs after bio is submitted, there is no memory free
operation for bio, which results in memory leakage. And there is also
no check against bio_alloc() for bio.

Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Signed-off-by: Jing Zhang <zj.barak@gmail.com>

---

--- o/fs/ext4/extents.c	2010-03-13 13:47:22.000000000 +0800
+++ c/fs/ext4/extents.c	2010-03-13 13:54:36.000000000 +0800
@@ -2568,6 +2568,10 @@ static int ext4_ext_zeroout(struct inode
 			len = ee_len;

 		bio = bio_alloc(GFP_NOIO, len);
+		if (! bio) {
+			ret = -ENOMEM;
+			break;
+		}	
 		bio->bi_sector = ee_pblock;
 		bio->bi_bdev   = inode->i_sb->s_bdev;

@@ -2598,6 +2602,7 @@ static int ext4_ext_zeroout(struct inode
 		if (test_bit(BIO_UPTODATE, &bio->bi_flags))
 			ret = 0;
 		else {
+			bio_put(bio);
 			ret = -EIO;
 			break;
 		}
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] memory leakage in ext4_ext_zeroout, jing zhang, (Fri Mar 12, 11:33 pm)