summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-core
diff options
context:
space:
mode:
authorWenwen Wang <wenwen@cs.uga.edu>2019-08-18 00:45:40 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 13:09:47 +0200
commit4df2427a5148093987437054bb82da4d014dcd59 (patch)
tree12d64a664982d8d7f863ec8a6b2bd00528ada52b /drivers/media/dvb-core
parent8d5fccff7b0c45b7b0b5e40ac983620eadda0a3b (diff)
downloadlinux-stable-4df2427a5148093987437054bb82da4d014dcd59.tar.gz
linux-stable-4df2427a5148093987437054bb82da4d014dcd59.tar.bz2
linux-stable-4df2427a5148093987437054bb82da4d014dcd59.zip
media: dvb-core: fix a memory leak bug
[ Upstream commit fcd5ce4b3936242e6679875a4d3c3acfc8743e15 ] In dvb_create_media_entity(), 'dvbdev->entity' is allocated through kzalloc(). Then, 'dvbdev->pads' is allocated through kcalloc(). However, if kcalloc() fails, the allocated 'dvbdev->entity' is not deallocated, leading to a memory leak bug. To fix this issue, free 'dvbdev->entity' before returning -ENOMEM. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/media/dvb-core')
-rw-r--r--drivers/media/dvb-core/dvbdev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 3c8778570331..04dc2f4bc7aa 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -339,8 +339,10 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
if (npads) {
dvbdev->pads = kcalloc(npads, sizeof(*dvbdev->pads),
GFP_KERNEL);
- if (!dvbdev->pads)
+ if (!dvbdev->pads) {
+ kfree(dvbdev->entity);
return -ENOMEM;
+ }
}
switch (type) {