* [PATCH] mm/block: logical error fix to avoid memory leak
@ 2017-12-14 5:03 Liu, Changcheng
2017-12-15 14:34 ` Adrian Hunter
0 siblings, 1 reply; 6+ messages in thread
From: Liu, Changcheng @ 2017-12-14 5:03 UTC (permalink / raw)
To: Ulf Hansson, Linus Walleij, Adrian Hunter; +Cc: linux-mmc, akpm, changcheng.liu
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@intel.com>
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/block: logical error fix to avoid memory leak
2017-12-14 5:03 [PATCH] mm/block: logical error fix to avoid memory leak Liu, Changcheng
@ 2017-12-15 14:34 ` Adrian Hunter
2017-12-16 15:15 ` [PATCH v2] mmc: block: fix logical error " Liu, Changcheng
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2017-12-15 14:34 UTC (permalink / raw)
To: Liu, Changcheng, Ulf Hansson, Linus Walleij; +Cc: linux-mmc, akpm
On 14/12/17 07:03, Liu, Changcheng wrote:
> 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@intel.com>
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:
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>
> 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;
> }
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mmc: block: fix logical error to avoid memory leak
2017-12-15 14:34 ` Adrian Hunter
@ 2017-12-16 15:15 ` Liu, Changcheng
2017-12-16 19:07 ` Linus Walleij
2017-12-18 13:05 ` Ulf Hansson
0 siblings, 2 replies; 6+ messages in thread
From: Liu, Changcheng @ 2017-12-16 15:15 UTC (permalink / raw)
To: Adrian Hunter, ulf.hansson, linus.walleij; +Cc: linux-mmc, akpm, changcheng.liu
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.
Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mmc: block: fix logical error to avoid memory leak
2017-12-16 15:15 ` [PATCH v2] mmc: block: fix logical error " Liu, Changcheng
@ 2017-12-16 19:07 ` Linus Walleij
2017-12-18 13:05 ` Ulf Hansson
1 sibling, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2017-12-16 19:07 UTC (permalink / raw)
To: Liu, Changcheng; +Cc: Adrian Hunter, Ulf Hansson, linux-mmc, Andrew Morton
On Sat, Dec 16, 2017 at 4:15 PM, Liu, Changcheng
<changcheng.liu@intel.com> wrote:
> 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.
>
> Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mmc: block: fix logical error to avoid memory leak
2017-12-16 15:15 ` [PATCH v2] mmc: block: fix logical error " Liu, Changcheng
2017-12-16 19:07 ` Linus Walleij
@ 2017-12-18 13:05 ` Ulf Hansson
2017-12-18 13:16 ` Liu, Changcheng
1 sibling, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2017-12-18 13:05 UTC (permalink / raw)
To: Liu, Changcheng; +Cc: Adrian Hunter, Linus Walleij, linux-mmc, Andrew Morton
On 16 December 2017 at 16:15, Liu, Changcheng <changcheng.liu@intel.com> wrote:
> 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.
>
> Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
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
>
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mmc: block: fix logical error to avoid memory leak
2017-12-18 13:05 ` Ulf Hansson
@ 2017-12-18 13:16 ` Liu, Changcheng
0 siblings, 0 replies; 6+ messages in thread
From: Liu, Changcheng @ 2017-12-18 13:16 UTC (permalink / raw)
To: Ulf Hansson, adrian.hunter; +Cc: linus.walleij, linux-mmc, akpm
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
On 21:05 Mon 18 Dec, Ulf Hansson wrote:
> On 16 December 2017 at 16:15, Liu, Changcheng <changcheng.liu@intel.com> wrote:
> > 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.
> >
> > Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
>
> 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
>
> >
> > 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-12-18 13:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 5:03 [PATCH] mm/block: logical error fix to avoid memory leak Liu, Changcheng
2017-12-15 14:34 ` Adrian Hunter
2017-12-16 15:15 ` [PATCH v2] mmc: block: fix logical error " Liu, Changcheng
2017-12-16 19:07 ` Linus Walleij
2017-12-18 13:05 ` Ulf Hansson
2017-12-18 13:16 ` Liu, Changcheng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.