diff mbox

[media] cx231xx: Fix memory leak

Message ID 1452287450-17623-1-git-send-email-jtheou@adeneo-embedded.us (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Baptiste Theou Jan. 8, 2016, 9:10 p.m. UTC
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(+)

Comments

kernel test robot Jan. 8, 2016, 9:55 p.m. UTC | #1
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
diff mbox

Patch

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) {