Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1216600 > unrolled thread

[PATCH] ASoC: wm0010: fix memory leak

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2015-09-01 07:50 +0200
Last post2015-09-01 11:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ASoC: wm0010: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-01 07:50 +0200
    Re: [PATCH] ASoC: wm0010: fix memory leak Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2015-09-01 11:00 +0200

#1216600 — [PATCH] ASoC: wm0010: fix memory leak

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-09-01 07:50 +0200
Subject[PATCH] ASoC: wm0010: fix memory leak
Message-ID<q3MCf-5Sy-13@gated-at.bofh.it>
We were aborting if the kzalloc of img_swap fails but without freeing the
already allocated out. Similarly we were aborting if spi_sync fails
without releasing out and img_swap.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 sound/soc/codecs/wm0010.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
index f2c6ad4..8434d45 100644
--- a/sound/soc/codecs/wm0010.c
+++ b/sound/soc/codecs/wm0010.c
@@ -672,8 +672,10 @@ static int wm0010_boot(struct snd_soc_codec *codec)
 		}
 
 		img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA);
-		if (!img_swap)
+		if (!img_swap) {
+			kfree(out);
 			goto abort;
+		}
 
 		/* We need to re-order for 0010 */
 		byte_swap_64((u64 *)&pll_rec, img_swap, len);
@@ -690,6 +692,8 @@ static int wm0010_boot(struct snd_soc_codec *codec)
 		ret = spi_sync(spi, &m);
 		if (ret != 0) {
 			dev_err(codec->dev, "First PLL write failed: %d\n", ret);
+			kfree(img_swap);
+			kfree(out);
 			goto abort;
 		}
 
@@ -697,6 +701,8 @@ static int wm0010_boot(struct snd_soc_codec *codec)
 		ret = spi_sync(spi, &m);
 		if (ret != 0) {
 			dev_err(codec->dev, "Second PLL write failed: %d\n", ret);
+			kfree(img_swap);
+			kfree(out);
 			goto abort;
 		}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1216702

FromCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Date2015-09-01 11:00 +0200
Message-ID<q3PA6-1Ef-23@gated-at.bofh.it>
In reply to#1216600
On Tue, Sep 01, 2015 at 11:14:05AM +0530, Sudip Mukherjee wrote:
> We were aborting if the kzalloc of img_swap fails but without freeing the
> already allocated out. Similarly we were aborting if spi_sync fails
> without releasing out and img_swap.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web