media: DaVinci-VPBE: fix error handling in vpbe_initialize()
If vpbe_set_default_output() or vpbe_set_default_mode() fails, vpbe_initialize() returns error code without releasing resources. The patch adds error handling for that case. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
adcfdbde20
commit
aa35dc3c71
|
@ -718,7 +718,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s",
|
v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s",
|
||||||
def_output);
|
def_output);
|
||||||
return ret;
|
goto fail_kfree_amp;
|
||||||
}
|
}
|
||||||
|
|
||||||
printk(KERN_NOTICE "Setting default mode to %s\n", def_mode);
|
printk(KERN_NOTICE "Setting default mode to %s\n", def_mode);
|
||||||
|
@ -726,12 +726,15 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s",
|
v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s",
|
||||||
def_mode);
|
def_mode);
|
||||||
return ret;
|
goto fail_kfree_amp;
|
||||||
}
|
}
|
||||||
vpbe_dev->initialized = 1;
|
vpbe_dev->initialized = 1;
|
||||||
/* TBD handling of bootargs for default output and mode */
|
/* TBD handling of bootargs for default output and mode */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail_kfree_amp:
|
||||||
|
mutex_lock(&vpbe_dev->lock);
|
||||||
|
kfree(vpbe_dev->amp);
|
||||||
fail_kfree_encoders:
|
fail_kfree_encoders:
|
||||||
kfree(vpbe_dev->encoders);
|
kfree(vpbe_dev->encoders);
|
||||||
fail_dev_unregister:
|
fail_dev_unregister:
|
||||||
|
|
Loading…
Reference in New Issue