aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2015-02-13 17:39:03 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-03-02 12:46:48 -0500
commit2160abb2945831aaf50d176ef6d070bdbd19130d (patch)
treeb4fcd96ae00ae56a8bf24f3a42d45902ec3553a7
parent6ab6a026bc2c8a88aaaa6df86ea543280e25e0f1 (diff)
[media] sh_vou: fix memory leak on error paths in sh_vou_open()
Memory allocated for sh_vou_file is not deallocated on error paths in sh_vou_open(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/platform/sh_vou.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 261f1195b49f..6d1959d1ad02 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -1168,10 +1168,10 @@ static int sh_vou_open(struct file *file)
1168 1168
1169 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); 1169 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
1170 1170
1171 file->private_data = vou_file; 1171 if (mutex_lock_interruptible(&vou_dev->fop_lock)) {
1172 1172 kfree(vou_file);
1173 if (mutex_lock_interruptible(&vou_dev->fop_lock))
1174 return -ERESTARTSYS; 1173 return -ERESTARTSYS;
1174 }
1175 if (atomic_inc_return(&vou_dev->use_count) == 1) { 1175 if (atomic_inc_return(&vou_dev->use_count) == 1) {
1176 int ret; 1176 int ret;
1177 /* First open */ 1177 /* First open */
@@ -1183,6 +1183,7 @@ static int sh_vou_open(struct file *file)
1183 pm_runtime_put(vou_dev->v4l2_dev.dev); 1183 pm_runtime_put(vou_dev->v4l2_dev.dev);
1184 vou_dev->status = SH_VOU_IDLE; 1184 vou_dev->status = SH_VOU_IDLE;
1185 mutex_unlock(&vou_dev->fop_lock); 1185 mutex_unlock(&vou_dev->fop_lock);
1186 kfree(vou_file);
1186 return ret; 1187 return ret;
1187 } 1188 }
1188 } 1189 }
@@ -1195,6 +1196,8 @@ static int sh_vou_open(struct file *file)
1195 vou_dev->vdev, &vou_dev->fop_lock); 1196 vou_dev->vdev, &vou_dev->fop_lock);
1196 mutex_unlock(&vou_dev->fop_lock); 1197 mutex_unlock(&vou_dev->fop_lock);
1197 1198
1199 file->private_data = vou_file;
1200
1198 return 0; 1201 return 0;
1199} 1202}
1200 1203