[PATCH] mm/block: logical error fix to avoid memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



function:  mmc_ext_csd_open
{
+-- 33 lines: struct mmc_card *card = inode->i_private;--
    if (n != EXT_CSD_STR_LEN) {
        err = -EINVAL;
        goto out_free;  //==>should free ext_csd firstly.
    }
+--  2 lines: filp->private_data = buf;------------------
    kfree(ext_csd);
    return 0;

out_free:
    kfree(buf);
    return err;
}

Signed-off-by: Liu Changcheng <changcheng.liu@xxxxxxxxx>

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index ccfa98a..b737a95 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2623,6 +2623,7 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 
 	if (n != EXT_CSD_STR_LEN) {
 		err = -EINVAL;
+		kfree(ext_csd);
 		goto out_free;
 	}
 
-- 
2.7.4

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



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux