* [PATCH] [media] cx231xx: Fix memory leak
@ 2016-01-08 21:10 Jean-Baptiste Theou
2016-01-08 21:55 ` kbuild test robot
2016-01-08 22:02 ` [PATCH v2] " Jean-Baptiste Theou
0 siblings, 2 replies; 4+ messages in thread
From: Jean-Baptiste Theou @ 2016-01-08 21:10 UTC (permalink / raw)
To: linux-media; +Cc: Jean-Baptiste Theou
dma_area needs to be freed when the device is close.
Based on em23xx-audio.c
Signed-off-by: Jean-Baptiste Theou <jtheou@adeneo-embedded.us>
---
drivers/media/usb/cx231xx/cx231xx-audio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c
index de4ae5e..2f3d7df 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -499,6 +499,11 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
}
dev->adev.users--;
+ if (substream->runtime->dma_area) {
+ dprintk("freeing\n");
+ vfree(substream->runtime->dma_area);
+ substream->runtime->dma_area = NULL;
+ }
mutex_unlock(&dev->lock);
if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] [media] cx231xx: Fix memory leak
2016-01-08 21:10 [PATCH] [media] cx231xx: Fix memory leak Jean-Baptiste Theou
@ 2016-01-08 21:55 ` kbuild test robot
2016-01-08 22:02 ` [PATCH v2] " Jean-Baptiste Theou
1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2016-01-08 21:55 UTC (permalink / raw)
To: Jean-Baptiste Theou; +Cc: kbuild-all, linux-media, Jean-Baptiste Theou
[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]
Hi Jean-Baptiste,
[auto build test ERROR on v4.4-rc8]
[also build test ERROR on next-20160108]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Jean-Baptiste-Theou/cx231xx-Fix-memory-leak/20160109-051910
config: x86_64-rhel (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/media/usb/cx231xx/cx231xx-audio.c: In function 'snd_cx231xx_pcm_close':
>> drivers/media/usb/cx231xx/cx231xx-audio.c:503:3: error: implicit declaration of function 'dprintk' [-Werror=implicit-function-declaration]
dprintk("freeing\n");
^
cc1: some warnings being treated as errors
vim +/dprintk +503 drivers/media/usb/cx231xx/cx231xx-audio.c
497 mutex_unlock(&dev->lock);
498 return ret;
499 }
500
501 dev->adev.users--;
502 if (substream->runtime->dma_area) {
> 503 dprintk("freeing\n");
504 vfree(substream->runtime->dma_area);
505 substream->runtime->dma_area = NULL;
506 }
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 35609 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2] [media] cx231xx: Fix memory leak
2016-01-08 21:10 [PATCH] [media] cx231xx: Fix memory leak Jean-Baptiste Theou
2016-01-08 21:55 ` kbuild test robot
@ 2016-01-08 22:02 ` Jean-Baptiste Theou
1 sibling, 0 replies; 4+ messages in thread
From: Jean-Baptiste Theou @ 2016-01-08 22:02 UTC (permalink / raw)
To: linux-media; +Cc: Jean-Baptiste Theou
dma_area needs to be freed when the device is closed.
Based on em23xx-audio.c
Signed-off-by: Jean-Baptiste Theou <jtheou@adeneo-embedded.us>
---
Changes in v2:
- Fix debug trace call
---
drivers/media/usb/cx231xx/cx231xx-audio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c
index de4ae5e..a6a9508 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -499,6 +499,11 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
}
dev->adev.users--;
+ if (substream->runtime->dma_area) {
+ dev_dbg(dev->dev, "freeing\n");
+ vfree(substream->runtime->dma_area);
+ substream->runtime->dma_area = NULL;
+ }
mutex_unlock(&dev->lock);
if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] [media] cx231xx: fix memory leak
@ 2016-03-07 10:22 Sudip Mukherjee
0 siblings, 0 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2016-03-07 10:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: linux-kernel, linux-media, Sudip Mukherjee
When we returned on error we missed freeing p_current_fw and p_buffer.
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
drivers/media/usb/cx231xx/cx231xx-417.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index c9320d6..3636d8d 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -966,6 +966,7 @@ static int cx231xx_load_firmware(struct cx231xx *dev)
p_buffer = vmalloc(4096);
if (p_buffer == NULL) {
dprintk(2, "FAIL!!!\n");
+ vfree(p_current_fw);
return -1;
}
@@ -989,6 +990,8 @@ static int cx231xx_load_firmware(struct cx231xx *dev)
if (retval != 0) {
dev_err(dev->dev,
"%s: Error with mc417_register_write\n", __func__);
+ vfree(p_current_fw);
+ vfree(p_buffer);
return -1;
}
@@ -1001,6 +1004,8 @@ static int cx231xx_load_firmware(struct cx231xx *dev)
CX231xx_FIRM_IMAGE_NAME);
dev_err(dev->dev,
"Please fix your hotplug setup, the board will not work without firmware loaded!\n");
+ vfree(p_current_fw);
+ vfree(p_buffer);
return -1;
}
@@ -1009,6 +1014,8 @@ static int cx231xx_load_firmware(struct cx231xx *dev)
"ERROR: Firmware size mismatch (have %zd, expected %d)\n",
firmware->size, CX231xx_FIRM_IMAGE_SIZE);
release_firmware(firmware);
+ vfree(p_current_fw);
+ vfree(p_buffer);
return -1;
}
@@ -1016,6 +1023,8 @@ static int cx231xx_load_firmware(struct cx231xx *dev)
dev_err(dev->dev,
"ERROR: Firmware magic mismatch, wrong file?\n");
release_firmware(firmware);
+ vfree(p_current_fw);
+ vfree(p_buffer);
return -1;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-07 10:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-08 21:10 [PATCH] [media] cx231xx: Fix memory leak Jean-Baptiste Theou
2016-01-08 21:55 ` kbuild test robot
2016-01-08 22:02 ` [PATCH v2] " Jean-Baptiste Theou
-- strict thread matches above, loose matches on Subject: below --
2016-03-07 10:22 [PATCH] [media] cx231xx: fix " Sudip Mukherjee
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).