* [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-20 6:12 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-20 6:12 UTC (permalink / raw) To: Liam Girdwood Cc: kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, Dong Aisheng, alsa-devel, linux-kernel From: Julia Lawall <julia@diku.dk> The error handling code prior to get_clk also needs to call kfree. The label name is changed to reflect its more general use. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- sound/soc/mxs/mxs-saif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..4a17bc8 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -523,8 +523,10 @@ static int mxs_saif_probe(struct platform_device *pdev) if (!saif) return -ENOMEM; - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) { + ret = -EINVAL; + goto failed; + } mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); @@ -532,7 +534,7 @@ static int mxs_saif_probe(struct platform_device *pdev) ret = PTR_ERR(saif->clk); dev_err(&pdev->dev, "Cannot get the clock: %d\n", ret); - goto failed_clk; + goto failed; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -625,7 +627,7 @@ failed_ioremap: release_mem_region(res->start, resource_size(res)); failed_get_resource: clk_put(saif->clk); -failed_clk: +failed: kfree(saif); return ret; ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-20 6:12 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-20 6:12 UTC (permalink / raw) To: Liam Girdwood Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Dong Aisheng From: Julia Lawall <julia@diku.dk> The error handling code prior to get_clk also needs to call kfree. The label name is changed to reflect its more general use. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- sound/soc/mxs/mxs-saif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..4a17bc8 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -523,8 +523,10 @@ static int mxs_saif_probe(struct platform_device *pdev) if (!saif) return -ENOMEM; - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) { + ret = -EINVAL; + goto failed; + } mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); @@ -532,7 +534,7 @@ static int mxs_saif_probe(struct platform_device *pdev) ret = PTR_ERR(saif->clk); dev_err(&pdev->dev, "Cannot get the clock: %d\n", ret); - goto failed_clk; + goto failed; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -625,7 +627,7 @@ failed_ioremap: release_mem_region(res->start, resource_size(res)); failed_get_resource: clk_put(saif->clk); -failed_clk: +failed: kfree(saif); return ret; ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-20 6:12 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-20 6:12 UTC (permalink / raw) To: Liam Girdwood Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Dong Aisheng From: Julia Lawall <julia@diku.dk> The error handling code prior to get_clk also needs to call kfree. The label name is changed to reflect its more general use. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- sound/soc/mxs/mxs-saif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..4a17bc8 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -523,8 +523,10 @@ static int mxs_saif_probe(struct platform_device *pdev) if (!saif) return -ENOMEM; - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) { + ret = -EINVAL; + goto failed; + } mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); @@ -532,7 +534,7 @@ static int mxs_saif_probe(struct platform_device *pdev) ret = PTR_ERR(saif->clk); dev_err(&pdev->dev, "Cannot get the clock: %d\n", ret); - goto failed_clk; + goto failed; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -625,7 +627,7 @@ failed_ioremap: release_mem_region(res->start, resource_size(res)); failed_get_resource: clk_put(saif->clk); -failed_clk: +failed: kfree(saif); return ret; ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-20 6:12 ` Julia Lawall (?) @ 2011-08-20 13:44 ` Wolfram Sang -1 siblings, 0 replies; 29+ messages in thread From: Wolfram Sang @ 2011-08-20 13:44 UTC (permalink / raw) To: Julia Lawall Cc: Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, Dong Aisheng, alsa-devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 815 bytes --] On Sat, Aug 20, 2011 at 08:12:40AM +0200, Julia Lawall wrote: > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c > index 0b3adae..4a17bc8 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -523,8 +523,10 @@ static int mxs_saif_probe(struct platform_device *pdev) > if (!saif) > return -ENOMEM; > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) { > + ret = -EINVAL; > + goto failed; > + } > mxs_saif[pdev->id] = saif; Thanks, Julia. May I suggest to simple move the id-check before the allocation? Regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-20 13:44 ` Wolfram Sang 0 siblings, 0 replies; 29+ messages in thread From: Wolfram Sang @ 2011-08-20 13:44 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Dong Aisheng, Liam Girdwood [-- Attachment #1.1: Type: text/plain, Size: 815 bytes --] On Sat, Aug 20, 2011 at 08:12:40AM +0200, Julia Lawall wrote: > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c > index 0b3adae..4a17bc8 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -523,8 +523,10 @@ static int mxs_saif_probe(struct platform_device *pdev) > if (!saif) > return -ENOMEM; > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) { > + ret = -EINVAL; > + goto failed; > + } > mxs_saif[pdev->id] = saif; Thanks, Julia. May I suggest to simple move the id-check before the allocation? Regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-20 13:44 ` Wolfram Sang 0 siblings, 0 replies; 29+ messages in thread From: Wolfram Sang @ 2011-08-20 13:44 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Dong Aisheng, Liam Girdwood [-- Attachment #1: Type: text/plain, Size: 815 bytes --] On Sat, Aug 20, 2011 at 08:12:40AM +0200, Julia Lawall wrote: > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c > index 0b3adae..4a17bc8 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -523,8 +523,10 @@ static int mxs_saif_probe(struct platform_device *pdev) > if (!saif) > return -ENOMEM; > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) { > + ret = -EINVAL; > + goto failed; > + } > mxs_saif[pdev->id] = saif; Thanks, Julia. May I suggest to simple move the id-check before the allocation? Regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-20 13:44 ` Wolfram Sang @ 2011-08-20 15:18 ` Julia Lawall -1 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-20 15:18 UTC (permalink / raw) To: Wolfram Sang Cc: Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, Dong Aisheng, alsa-devel, linux-kernel From: Julia Lawall <julia@diku.dk> Move the test on pdev->id before the kzalloc to avoid requiring kfree when the test fails. This fix was suggested by Wolfram Sang. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..e9a90e4 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device *pdev) struct mxs_saif *saif; int ret = 0; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) + return -EINVAL; saif = kzalloc(sizeof(*saif), GFP_KERNEL); if (!saif) return -ENOMEM; - - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-20 15:18 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-20 15:18 UTC (permalink / raw) To: Wolfram Sang Cc: Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, Dong Aisheng, alsa-devel, linux-kernel From: Julia Lawall <julia@diku.dk> Move the test on pdev->id before the kzalloc to avoid requiring kfree when the test fails. This fix was suggested by Wolfram Sang. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..e9a90e4 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device *pdev) struct mxs_saif *saif; int ret = 0; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) + return -EINVAL; saif = kzalloc(sizeof(*saif), GFP_KERNEL); if (!saif) return -ENOMEM; - - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); ^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-20 15:18 ` Julia Lawall (?) @ 2011-08-21 10:29 ` Dong Aisheng-B29396 -1 siblings, 0 replies; 29+ messages in thread From: Dong Aisheng-B29396 @ 2011-08-21 10:29 UTC (permalink / raw) To: Julia Lawall, Wolfram Sang Cc: Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel > -----Original Message----- > From: Julia Lawall [mailto:julia@diku.dk] > Sent: Saturday, August 20, 2011 11:19 PM > To: Wolfram Sang > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree > > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > when the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > --- > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > 0b3adae..e9a90e4 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device > *pdev) > struct mxs_saif *saif; > int ret = 0; > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > + return -EINVAL; > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > if (!saif) > return -ENOMEM; > - > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > mxs_saif[pdev->id] = saif; > > saif->clk = clk_get(&pdev->dev, NULL); Thanks for the finding, Julia. It's ok to me. BTW I guess you may need to resend a new version patch instead of following it in this mail thread. :) If yes, one minus thing, add one blank line below the line of 'return -ENOMEM' may look more comfortable. Regards Dong Aisheng ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 10:29 ` Dong Aisheng-B29396 0 siblings, 0 replies; 29+ messages in thread From: Dong Aisheng-B29396 @ 2011-08-21 10:29 UTC (permalink / raw) To: Julia Lawall, Wolfram Sang Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Liam Girdwood > -----Original Message----- > From: Julia Lawall [mailto:julia@diku.dk] > Sent: Saturday, August 20, 2011 11:19 PM > To: Wolfram Sang > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree > > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > when the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > --- > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > 0b3adae..e9a90e4 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device > *pdev) > struct mxs_saif *saif; > int ret = 0; > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > + return -EINVAL; > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > if (!saif) > return -ENOMEM; > - > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > mxs_saif[pdev->id] = saif; > > saif->clk = clk_get(&pdev->dev, NULL); Thanks for the finding, Julia. It's ok to me. BTW I guess you may need to resend a new version patch instead of following it in this mail thread. :) If yes, one minus thing, add one blank line below the line of 'return -ENOMEM' may look more comfortable. Regards Dong Aisheng ^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 10:29 ` Dong Aisheng-B29396 0 siblings, 0 replies; 29+ messages in thread From: Dong Aisheng-B29396 @ 2011-08-21 10:29 UTC (permalink / raw) To: Julia Lawall, Wolfram Sang Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Liam Girdwood > -----Original Message----- > From: Julia Lawall [mailto:julia@diku.dk] > Sent: Saturday, August 20, 2011 11:19 PM > To: Wolfram Sang > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree > > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > when the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > --- > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > 0b3adae..e9a90e4 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device > *pdev) > struct mxs_saif *saif; > int ret = 0; > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > + return -EINVAL; > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > if (!saif) > return -ENOMEM; > - > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > mxs_saif[pdev->id] = saif; > > saif->clk = clk_get(&pdev->dev, NULL); Thanks for the finding, Julia. It's ok to me. BTW I guess you may need to resend a new version patch instead of following it in this mail thread. :) If yes, one minus thing, add one blank line below the line of 'return -ENOMEM' may look more comfortable. Regards Dong Aisheng ^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-21 10:29 ` Dong Aisheng-B29396 (?) @ 2011-08-21 10:57 ` Julia Lawall -1 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-21 10:57 UTC (permalink / raw) To: Dong Aisheng-B29396 Cc: Wolfram Sang, Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel On Sun, 21 Aug 2011, Dong Aisheng-B29396 wrote: > > -----Original Message----- > > From: Julia Lawall [mailto:julia@diku.dk] > > Sent: Saturday, August 20, 2011 11:19 PM > > To: Wolfram Sang > > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav > > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree > > > > From: Julia Lawall <julia@diku.dk> > > > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > > when the test fails. This fix was suggested by Wolfram Sang. > > > > A simplified version of the semantic match that finds this problem is as > > follows: (http://coccinelle.lip6.fr/) > > > > // <smpl> > > @@ > > identifier x; > > expression E1!=0,E2,E3,E4; > > statement S; > > iterator I; > > @@ > > > > ( > > if (...) { ... when != kfree(x) > > when != x = E3 > > when != E3 = x > > * return ...; > > } > > ... when != x = E2 > > when != I(...,x,...) S > > if (...) { ... when != x = E4 > > kfree(x); ... return ...; } > > ) > > // </smpl> > > > > Signed-off-by: Julia Lawall <julia@diku.dk> > > > > --- > > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > > 0b3adae..e9a90e4 100644 > > --- a/sound/soc/mxs/mxs-saif.c > > +++ b/sound/soc/mxs/mxs-saif.c > > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device > > *pdev) > > struct mxs_saif *saif; > > int ret = 0; > > > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > > + return -EINVAL; > > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > > if (!saif) > > return -ENOMEM; > > - > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > > - return -EINVAL; > > mxs_saif[pdev->id] = saif; > > > > saif->clk = clk_get(&pdev->dev, NULL); > > Thanks for the finding, Julia. > It's ok to me. > > BTW I guess you may need to resend a new version patch instead of following it > in this mail thread. :) > If yes, one minus thing, add one blank line below the line of 'return -ENOMEM' > may look more comfortable. OK, I will do both. Thanks, julia ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 10:57 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-21 10:57 UTC (permalink / raw) To: Dong Aisheng-B29396 Cc: alsa-devel, Takashi Iwai, linux-kernel, Mark Brown, kernel-janitors, Wolfram Sang, Liam Girdwood On Sun, 21 Aug 2011, Dong Aisheng-B29396 wrote: > > -----Original Message----- > > From: Julia Lawall [mailto:julia@diku.dk] > > Sent: Saturday, August 20, 2011 11:19 PM > > To: Wolfram Sang > > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav > > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree > > > > From: Julia Lawall <julia@diku.dk> > > > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > > when the test fails. This fix was suggested by Wolfram Sang. > > > > A simplified version of the semantic match that finds this problem is as > > follows: (http://coccinelle.lip6.fr/) > > > > // <smpl> > > @@ > > identifier x; > > expression E1!=0,E2,E3,E4; > > statement S; > > iterator I; > > @@ > > > > ( > > if (...) { ... when != kfree(x) > > when != x = E3 > > when != E3 = x > > * return ...; > > } > > ... when != x = E2 > > when != I(...,x,...) S > > if (...) { ... when != x = E4 > > kfree(x); ... return ...; } > > ) > > // </smpl> > > > > Signed-off-by: Julia Lawall <julia@diku.dk> > > > > --- > > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > > 0b3adae..e9a90e4 100644 > > --- a/sound/soc/mxs/mxs-saif.c > > +++ b/sound/soc/mxs/mxs-saif.c > > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device > > *pdev) > > struct mxs_saif *saif; > > int ret = 0; > > > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > > + return -EINVAL; > > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > > if (!saif) > > return -ENOMEM; > > - > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > > - return -EINVAL; > > mxs_saif[pdev->id] = saif; > > > > saif->clk = clk_get(&pdev->dev, NULL); > > Thanks for the finding, Julia. > It's ok to me. > > BTW I guess you may need to resend a new version patch instead of following it > in this mail thread. :) > If yes, one minus thing, add one blank line below the line of 'return -ENOMEM' > may look more comfortable. OK, I will do both. Thanks, julia ^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 10:57 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-21 10:57 UTC (permalink / raw) To: Dong Aisheng-B29396 Cc: alsa-devel, Takashi Iwai, linux-kernel, Mark Brown, kernel-janitors, Wolfram Sang, Liam Girdwood On Sun, 21 Aug 2011, Dong Aisheng-B29396 wrote: > > -----Original Message----- > > From: Julia Lawall [mailto:julia@diku.dk] > > Sent: Saturday, August 20, 2011 11:19 PM > > To: Wolfram Sang > > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav > > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree > > > > From: Julia Lawall <julia@diku.dk> > > > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > > when the test fails. This fix was suggested by Wolfram Sang. > > > > A simplified version of the semantic match that finds this problem is as > > follows: (http://coccinelle.lip6.fr/) > > > > // <smpl> > > @@ > > identifier x; > > expression E1!=0,E2,E3,E4; > > statement S; > > iterator I; > > @@ > > > > ( > > if (...) { ... when != kfree(x) > > when != x = E3 > > when != E3 = x > > * return ...; > > } > > ... when != x = E2 > > when != I(...,x,...) S > > if (...) { ... when != x = E4 > > kfree(x); ... return ...; } > > ) > > // </smpl> > > > > Signed-off-by: Julia Lawall <julia@diku.dk> > > > > --- > > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > > 0b3adae..e9a90e4 100644 > > --- a/sound/soc/mxs/mxs-saif.c > > +++ b/sound/soc/mxs/mxs-saif.c > > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device > > *pdev) > > struct mxs_saif *saif; > > int ret = 0; > > > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > > + return -EINVAL; > > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > > if (!saif) > > return -ENOMEM; > > - > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > > - return -EINVAL; > > mxs_saif[pdev->id] = saif; > > > > saif->clk = clk_get(&pdev->dev, NULL); > > Thanks for the finding, Julia. > It's ok to me. > > BTW I guess you may need to resend a new version patch instead of following it > in this mail thread. :) > If yes, one minus thing, add one blank line below the line of 'return -ENOMEM' > may look more comfortable. OK, I will do both. Thanks, julia ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-21 10:29 ` Dong Aisheng-B29396 (?) @ 2011-08-21 11:18 ` Julia Lawall -1 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-21 11:18 UTC (permalink / raw) To: Dong Aisheng-B29396 Cc: Wolfram Sang, Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel From: Julia Lawall <julia@diku.dk> Move the test on pdev->id before the kzalloc to avoid requiring kfree when the test fails. This fix was suggested by Wolfram Sang. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- sound/soc/mxs/mxs-saif.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..ab453ca 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -519,12 +519,13 @@ static int mxs_saif_probe(struct platform_device *pdev) struct mxs_saif *saif; int ret = 0; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) + return -EINVAL; + saif = kzalloc(sizeof(*saif), GFP_KERNEL); if (!saif) return -ENOMEM; - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 11:18 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-21 11:18 UTC (permalink / raw) To: Dong Aisheng-B29396 Cc: alsa-devel, Takashi Iwai, linux-kernel, Mark Brown, kernel-janitors, Wolfram Sang, Liam Girdwood From: Julia Lawall <julia@diku.dk> Move the test on pdev->id before the kzalloc to avoid requiring kfree when the test fails. This fix was suggested by Wolfram Sang. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- sound/soc/mxs/mxs-saif.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..ab453ca 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -519,12 +519,13 @@ static int mxs_saif_probe(struct platform_device *pdev) struct mxs_saif *saif; int ret = 0; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) + return -EINVAL; + saif = kzalloc(sizeof(*saif), GFP_KERNEL); if (!saif) return -ENOMEM; - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); ^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 11:18 ` Julia Lawall 0 siblings, 0 replies; 29+ messages in thread From: Julia Lawall @ 2011-08-21 11:18 UTC (permalink / raw) To: Dong Aisheng-B29396 Cc: alsa-devel, Takashi Iwai, linux-kernel, Mark Brown, kernel-janitors, Wolfram Sang, Liam Girdwood From: Julia Lawall <julia@diku.dk> Move the test on pdev->id before the kzalloc to avoid requiring kfree when the test fails. This fix was suggested by Wolfram Sang. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier x; expression E1!=0,E2,E3,E4; statement S; iterator I; @@ ( if (...) { ... when != kfree(x) when != x = E3 when != E3 = x * return ...; } ... when != x = E2 when != I(...,x,...) S if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- sound/soc/mxs/mxs-saif.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 0b3adae..ab453ca 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -519,12 +519,13 @@ static int mxs_saif_probe(struct platform_device *pdev) struct mxs_saif *saif; int ret = 0; + if (pdev->id >= ARRAY_SIZE(mxs_saif)) + return -EINVAL; + saif = kzalloc(sizeof(*saif), GFP_KERNEL); if (!saif) return -ENOMEM; - if (pdev->id >= ARRAY_SIZE(mxs_saif)) - return -EINVAL; mxs_saif[pdev->id] = saif; saif->clk = clk_get(&pdev->dev, NULL); ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-21 11:18 ` Julia Lawall (?) @ 2011-08-21 11:29 ` Wolfram Sang -1 siblings, 0 replies; 29+ messages in thread From: Wolfram Sang @ 2011-08-21 11:29 UTC (permalink / raw) To: Julia Lawall Cc: Dong Aisheng-B29396, Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1004 bytes --] On Sun, Aug 21, 2011 at 01:18:45PM +0200, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 11:29 ` Wolfram Sang 0 siblings, 0 replies; 29+ messages in thread From: Wolfram Sang @ 2011-08-21 11:29 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Dong Aisheng-B29396, Liam Girdwood [-- Attachment #1.1: Type: text/plain, Size: 1004 bytes --] On Sun, Aug 21, 2011 at 01:18:45PM +0200, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 11:29 ` Wolfram Sang 0 siblings, 0 replies; 29+ messages in thread From: Wolfram Sang @ 2011-08-21 11:29 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors, linux-kernel, Dong Aisheng-B29396, Liam Girdwood [-- Attachment #1: Type: text/plain, Size: 1004 bytes --] On Sun, Aug 21, 2011 at 01:18:45PM +0200, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-21 11:18 ` Julia Lawall (?) @ 2011-08-21 13:40 ` Dong Aisheng-B29396 -1 siblings, 0 replies; 29+ messages in thread From: Dong Aisheng-B29396 @ 2011-08-21 13:40 UTC (permalink / raw) To: Julia Lawall Cc: Wolfram Sang, Liam Girdwood, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel > -----Original Message----- > From: Julia Lawall [mailto:julia@diku.dk] > Sent: Sunday, August 21, 2011 7:19 PM > To: Dong Aisheng-B29396 > Cc: Wolfram Sang; Liam Girdwood; kernel-janitors@vger.kernel.org; Mark > Brown; Jaroslav Kysela; Takashi Iwai; alsa-devel@alsa-project.org; linux- > kernel@vger.kernel.org > Subject: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree > > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > when the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > --- > sound/soc/mxs/mxs-saif.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > 0b3adae..ab453ca 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -519,12 +519,13 @@ static int mxs_saif_probe(struct platform_device > *pdev) > struct mxs_saif *saif; > int ret = 0; > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > + return -EINVAL; > + > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > if (!saif) > return -ENOMEM; > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > mxs_saif[pdev->id] = saif; > > saif->clk = clk_get(&pdev->dev, NULL); Acked-by: Dong Aisheng <b29396@freescale.com> Regards Dong Aisheng ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 13:40 ` Dong Aisheng-B29396 0 siblings, 0 replies; 29+ messages in thread From: Dong Aisheng-B29396 @ 2011-08-21 13:40 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, linux-kernel, Brown, kernel-janitors, Wolfram Sang, Mark, Liam Girdwood > -----Original Message----- > From: Julia Lawall [mailto:julia@diku.dk] > Sent: Sunday, August 21, 2011 7:19 PM > To: Dong Aisheng-B29396 > Cc: Wolfram Sang; Liam Girdwood; kernel-janitors@vger.kernel.org; Mark > Brown; Jaroslav Kysela; Takashi Iwai; alsa-devel@alsa-project.org; linux- > kernel@vger.kernel.org > Subject: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree > > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > when the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > --- > sound/soc/mxs/mxs-saif.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > 0b3adae..ab453ca 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -519,12 +519,13 @@ static int mxs_saif_probe(struct platform_device > *pdev) > struct mxs_saif *saif; > int ret = 0; > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > + return -EINVAL; > + > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > if (!saif) > return -ENOMEM; > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > mxs_saif[pdev->id] = saif; > > saif->clk = clk_get(&pdev->dev, NULL); Acked-by: Dong Aisheng <b29396@freescale.com> Regards Dong Aisheng ^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-21 13:40 ` Dong Aisheng-B29396 0 siblings, 0 replies; 29+ messages in thread From: Dong Aisheng-B29396 @ 2011-08-21 13:40 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, linux-kernel, Brown, kernel-janitors, Wolfram Sang, Mark, Liam Girdwood > -----Original Message----- > From: Julia Lawall [mailto:julia@diku.dk] > Sent: Sunday, August 21, 2011 7:19 PM > To: Dong Aisheng-B29396 > Cc: Wolfram Sang; Liam Girdwood; kernel-janitors@vger.kernel.org; Mark > Brown; Jaroslav Kysela; Takashi Iwai; alsa-devel@alsa-project.org; linux- > kernel@vger.kernel.org > Subject: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree > > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree > when the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > --- > sound/soc/mxs/mxs-saif.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index > 0b3adae..ab453ca 100644 > --- a/sound/soc/mxs/mxs-saif.c > +++ b/sound/soc/mxs/mxs-saif.c > @@ -519,12 +519,13 @@ static int mxs_saif_probe(struct platform_device > *pdev) > struct mxs_saif *saif; > int ret = 0; > > + if (pdev->id >= ARRAY_SIZE(mxs_saif)) > + return -EINVAL; > + > saif = kzalloc(sizeof(*saif), GFP_KERNEL); > if (!saif) > return -ENOMEM; > > - if (pdev->id >= ARRAY_SIZE(mxs_saif)) > - return -EINVAL; > mxs_saif[pdev->id] = saif; > > saif->clk = clk_get(&pdev->dev, NULL); Acked-by: Dong Aisheng <b29396@freescale.com> Regards Dong Aisheng ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-21 11:18 ` Julia Lawall (?) @ 2011-08-22 10:21 ` Liam Girdwood -1 siblings, 0 replies; 29+ messages in thread From: Liam Girdwood @ 2011-08-22 10:21 UTC (permalink / raw) To: Julia Lawall Cc: Dong Aisheng-B29396, Wolfram Sang, kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel On 21/08/11 12:18, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > Acked-by: Liam Girdwood <lrg@ti.com> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-22 10:21 ` Liam Girdwood 0 siblings, 0 replies; 29+ messages in thread From: Liam Girdwood @ 2011-08-22 10:21 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, linux-kernel, Mark Brown, kernel-janitors, Wolfram Sang, Dong Aisheng-B29396 On 21/08/11 12:18, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > Acked-by: Liam Girdwood <lrg@ti.com> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-22 10:21 ` Liam Girdwood 0 siblings, 0 replies; 29+ messages in thread From: Liam Girdwood @ 2011-08-22 10:21 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, linux-kernel, Mark Brown, kernel-janitors, Wolfram Sang, Dong Aisheng-B29396 On 21/08/11 12:18, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // <smpl> > @@ > identifier x; > expression E1!=0,E2,E3,E4; > statement S; > iterator I; > @@ > > ( > if (...) { ... when != kfree(x) > when != x = E3 > when != E3 = x > * return ...; > } > ... when != x = E2 > when != I(...,x,...) S > if (...) { ... when != x = E4 > kfree(x); ... return ...; } > ) > // </smpl> > > Signed-off-by: Julia Lawall <julia@diku.dk> > > Acked-by: Liam Girdwood <lrg@ti.com> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree 2011-08-21 11:18 ` Julia Lawall (?) @ 2011-08-22 22:35 ` Mark Brown -1 siblings, 0 replies; 29+ messages in thread From: Mark Brown @ 2011-08-22 22:35 UTC (permalink / raw) To: Julia Lawall Cc: Dong Aisheng-B29396, Wolfram Sang, Liam Girdwood, kernel-janitors, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel On Sun, Aug 21, 2011 at 01:18:45PM +0200, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > Applied, thanks. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-22 22:35 ` Mark Brown 0 siblings, 0 replies; 29+ messages in thread From: Mark Brown @ 2011-08-22 22:35 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, linux-kernel, kernel-janitors, Wolfram Sang, Dong Aisheng-B29396, Liam Girdwood On Sun, Aug 21, 2011 at 01:18:45PM +0200, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > Applied, thanks. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] sound/soc/mxs/mxs-saif.c: add missing kfree @ 2011-08-22 22:35 ` Mark Brown 0 siblings, 0 replies; 29+ messages in thread From: Mark Brown @ 2011-08-22 22:35 UTC (permalink / raw) To: Julia Lawall Cc: alsa-devel, Takashi Iwai, linux-kernel, kernel-janitors, Wolfram Sang, Dong Aisheng-B29396, Liam Girdwood On Sun, Aug 21, 2011 at 01:18:45PM +0200, Julia Lawall wrote: > From: Julia Lawall <julia@diku.dk> > > Move the test on pdev->id before the kzalloc to avoid requiring kfree when > the test fails. This fix was suggested by Wolfram Sang. > Applied, thanks. ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2011-08-22 22:35 UTC | newest] Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-08-20 6:12 [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree Julia Lawall 2011-08-20 6:12 ` Julia Lawall 2011-08-20 6:12 ` Julia Lawall 2011-08-20 13:44 ` Wolfram Sang 2011-08-20 13:44 ` Wolfram Sang 2011-08-20 13:44 ` Wolfram Sang 2011-08-20 15:18 ` Julia Lawall 2011-08-20 15:18 ` Julia Lawall 2011-08-21 10:29 ` Dong Aisheng-B29396 2011-08-21 10:29 ` Dong Aisheng-B29396 2011-08-21 10:29 ` Dong Aisheng-B29396 2011-08-21 10:57 ` Julia Lawall 2011-08-21 10:57 ` Julia Lawall 2011-08-21 10:57 ` Julia Lawall 2011-08-21 11:18 ` [PATCH] " Julia Lawall 2011-08-21 11:18 ` Julia Lawall 2011-08-21 11:18 ` Julia Lawall 2011-08-21 11:29 ` Wolfram Sang 2011-08-21 11:29 ` Wolfram Sang 2011-08-21 11:29 ` Wolfram Sang 2011-08-21 13:40 ` Dong Aisheng-B29396 2011-08-21 13:40 ` Dong Aisheng-B29396 2011-08-21 13:40 ` Dong Aisheng-B29396 2011-08-22 10:21 ` Liam Girdwood 2011-08-22 10:21 ` Liam Girdwood 2011-08-22 10:21 ` Liam Girdwood 2011-08-22 22:35 ` Mark Brown 2011-08-22 22:35 ` Mark Brown 2011-08-22 22:35 ` Mark Brown
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.