Commit 2160abb2 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Mauro Carvalho Chehab

[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: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 6ab6a026
...@@ -1168,10 +1168,10 @@ static int sh_vou_open(struct file *file) ...@@ -1168,10 +1168,10 @@ static int sh_vou_open(struct file *file)
dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
file->private_data = vou_file; if (mutex_lock_interruptible(&vou_dev->fop_lock)) {
kfree(vou_file);
if (mutex_lock_interruptible(&vou_dev->fop_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
}
if (atomic_inc_return(&vou_dev->use_count) == 1) { if (atomic_inc_return(&vou_dev->use_count) == 1) {
int ret; int ret;
/* First open */ /* First open */
...@@ -1183,6 +1183,7 @@ static int sh_vou_open(struct file *file) ...@@ -1183,6 +1183,7 @@ static int sh_vou_open(struct file *file)
pm_runtime_put(vou_dev->v4l2_dev.dev); pm_runtime_put(vou_dev->v4l2_dev.dev);
vou_dev->status = SH_VOU_IDLE; vou_dev->status = SH_VOU_IDLE;
mutex_unlock(&vou_dev->fop_lock); mutex_unlock(&vou_dev->fop_lock);
kfree(vou_file);
return ret; return ret;
} }
} }
...@@ -1195,6 +1196,8 @@ static int sh_vou_open(struct file *file) ...@@ -1195,6 +1196,8 @@ static int sh_vou_open(struct file *file)
vou_dev->vdev, &vou_dev->fop_lock); vou_dev->vdev, &vou_dev->fop_lock);
mutex_unlock(&vou_dev->fop_lock); mutex_unlock(&vou_dev->fop_lock);
file->private_data = vou_file;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment