alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c
@ 2013-10-12 22:35 Felipe Pena
  2013-10-14  8:53 ` [alsa-devel] " Sascha Hauer
  2013-10-14 11:59 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Felipe Pena @ 2013-10-12 22:35 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Fabio Estevam, Markus Pargmann, Bill Pemberton,
	Greg Kroah-Hartman
  Cc: alsa-devel, linux-kernel, Felipe Pena

When audmux_clk is used and clk_prepare_enable function succeed,
the memory alloc'd to buf variable is leaked

Signed-off-by: Felipe Pena <felipensp@gmail.com>
---
 sound/soc/fsl/imx-audmux.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index d3bf71a..ac86993 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
 				size_t count, loff_t *ppos)
 {
 	ssize_t ret;
-	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	char *buf;
 	int port = (int)file->private_data;
 	u32 pdcr, ptcr;
 
-	if (!buf)
-		return -ENOMEM;
-
 	if (audmux_clk) {
 		ret = clk_prepare_enable(audmux_clk);
 		if (ret)
@@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
 	if (audmux_clk)
 		clk_disable_unprepare(audmux_clk);
 
+	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
 	ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
 		       pdcr, ptcr);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [alsa-devel] [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c
  2013-10-12 22:35 [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c Felipe Pena
@ 2013-10-14  8:53 ` Sascha Hauer
  2013-10-14 11:59 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-10-14  8:53 UTC (permalink / raw)
  To: Felipe Pena
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Fabio Estevam, Markus Pargmann, Bill Pemberton,
	Greg Kroah-Hartman, alsa-devel, linux-kernel

On Sat, Oct 12, 2013 at 07:35:06PM -0300, Felipe Pena wrote:
> When audmux_clk is used and clk_prepare_enable function succeed,
> the memory alloc'd to buf variable is leaked
> 
> Signed-off-by: Felipe Pena <felipensp@gmail.com>

Looks good.

Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>

If you send a v2 please next time also write what changed to the
previous version.

Sascha

> ---
>  sound/soc/fsl/imx-audmux.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
> index d3bf71a..ac86993 100644
> --- a/sound/soc/fsl/imx-audmux.c
> +++ b/sound/soc/fsl/imx-audmux.c
> @@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
>  				size_t count, loff_t *ppos)
>  {
>  	ssize_t ret;
> -	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +	char *buf;
>  	int port = (int)file->private_data;
>  	u32 pdcr, ptcr;
>  
> -	if (!buf)
> -		return -ENOMEM;
> -
>  	if (audmux_clk) {
>  		ret = clk_prepare_enable(audmux_clk);
>  		if (ret)
> @@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
>  	if (audmux_clk)
>  		clk_disable_unprepare(audmux_clk);
>  
> +	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
>  	ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
>  		       pdcr, ptcr);
>  
> -- 
> 1.7.10.4
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c
  2013-10-12 22:35 [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c Felipe Pena
  2013-10-14  8:53 ` [alsa-devel] " Sascha Hauer
@ 2013-10-14 11:59 ` Mark Brown
  2013-10-14 12:05   ` Felipe Pena
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2013-10-14 11:59 UTC (permalink / raw)
  To: Felipe Pena
  Cc: Fabio Estevam, alsa-devel, Takashi Iwai, Greg Kroah-Hartman,
	Liam Girdwood, Bill Pemberton, Markus Pargmann, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 464 bytes --]

On Sat, Oct 12, 2013 at 07:35:06PM -0300, Felipe Pena wrote:
> When audmux_clk is used and clk_prepare_enable function succeed,
> the memory alloc'd to buf variable is leaked

Applied, thanks.  Please try to use subject lines appropriate for the
subsystem and keep your CC lists focused - you want to send to
maintainers and people working on the specific code but it's best to
avoid people working on tree wide cleanups like Bill so they don't get
too much spam.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c
  2013-10-14 11:59 ` Mark Brown
@ 2013-10-14 12:05   ` Felipe Pena
  2013-10-14 12:27     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Pena @ 2013-10-14 12:05 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Fabio Estevam,
	Markus Pargmann, Bill Pemberton, Greg Kroah-Hartman, alsa-devel,
	linux-kernel

Hi,

On Mon, Oct 14, 2013 at 8:59 AM, Mark Brown <broonie@kernel.org> wrote:
> On Sat, Oct 12, 2013 at 07:35:06PM -0300, Felipe Pena wrote:
>> When audmux_clk is used and clk_prepare_enable function succeed,
>> the memory alloc'd to buf variable is leaked
>
> Applied, thanks.  Please try to use subject lines appropriate for the
> subsystem and keep your CC lists focused - you want to send to
> maintainers and people working on the specific code but it's best to
> avoid people working on tree wide cleanups like Bill so they don't get
> too much spam.

Thanks guys for accepting the patch. Sorry for inconvenience about the
subject line.

About the CC list I just use the one that I get from scripts/get_maintainer.pl.

-- 
Regards,
Felipe Pena

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c
  2013-10-14 12:05   ` Felipe Pena
@ 2013-10-14 12:27     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-10-14 12:27 UTC (permalink / raw)
  To: Felipe Pena
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Fabio Estevam,
	Markus Pargmann, Bill Pemberton, Greg Kroah-Hartman, alsa-devel,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 399 bytes --]

On Mon, Oct 14, 2013 at 09:05:44AM -0300, Felipe Pena wrote:

> About the CC list I just use the one that I get from scripts/get_maintainer.pl.

Yeah, that's the most common reason - get_maintianer tends to pick up
extra people.  You really need to look at the list of people it
generates and why they're there, if they're there due to git commits
they might just have been doing some generic work.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-14 12:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-12 22:35 [PATCH v2] sound: soc: fsl: Fix memory leak in imx-audmux.c Felipe Pena
2013-10-14  8:53 ` [alsa-devel] " Sascha Hauer
2013-10-14 11:59 ` Mark Brown
2013-10-14 12:05   ` Felipe Pena
2013-10-14 12:27     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).