mm/block: logical error fix to avoid memory leak
PATCH 1/1 mm/block: logical error fix to avoid memory leak
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;
}drivers/mmc/core/block.c +1 -0
@@ -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; }
Signature · 1 line
2.7.4
Quoted 11 lines · Changcheng
function:
mmc_ext_csd_open
{
+-- 33 lines: structmmc_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;
Quoted 6 lines
out_free:kfree(buf); return err; }Signed-off-by Liu Changcheng <[email protected]>
Well I don't really follow the commit message, but the patch is OK. How about this:
mmc: block: fix logical error to avoid memory leak
If the MMC_DRV_OP_GET_EXT_CSD request completes successfully, then ext_csd must be freed, but in one case it was not. Fix that.
Otherwise:
Quoted 14 lines
drivers/mmc/core/block.c +1
-0@@ -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; }
Re: [PATCH v2] mmc: block: fix logical error to avoid memory leak
If the MMC_DRV_OP_GET_EXT_CSD request completes successfully, then ext_csd must be freed, but in one case it was not. Fix that.
drivers/mmc/core/block.c +1 -0
@@ -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; }
Signature · 1 line
2.7.4
Linus Walleij
Acked-byRe: [PATCH v2] mmc: block: fix logical error to avoid memory leak
Quoted 4 lines · Changcheng
If the
MMC_DRV_OP_GET_EXT_CSDrequest completes successfully, thenext_csdmust be freed, but in one case it was not. Fix that.Signed-off-by Liu Changcheng <[email protected]>
Yours,
Linus Walleij
Ulf Hansson
AppliedRe: [PATCH v2] mmc: block: fix logical error to avoid memory leak
In reply to Liu, ChangchengQuoted 4 lines · Changcheng
If the
MMC_DRV_OP_GET_EXT_CSDrequest completes successfully, thenext_csdmust be freed, but in one case it was not. Fix that.Signed-off-by Liu Changcheng <[email protected]>
Thanks, applied for next!
Next time, you may please preserve acks from previous versions, especially if the reviewer (Adrian in this case) says so.
Kind regards
Uffe
Quoted 15 lines
drivers/mmc/core/block.c +1
-1@@ -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
Re: [PATCH v2] mmc: block: fix logical error to avoid memory leak
Hi Uffe,
Thx for your guide. I'm on the way to work with community. I'll
follow your suggestion next time.
B.R.
Changcheng
Quoted 29 lines · Ulf Hansson
Quoted 4 lines · Changcheng
If the
MMC_DRV_OP_GET_EXT_CSDrequest completes successfully, thenext_csdmust be freed, but in one case it was not. Fix that.Signed-off-by Liu Changcheng <[email protected]>Thanks, applied for next!
Next time, you may please preserve acks from previous versions, especially if the reviewer (Adrian in this case) says so.
Kind regards
UffeQuoted 15 lines
drivers/mmc/core/block.c +1
-1@@ -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