Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexey Khoroshilov and committed by
Mauro Carvalho Chehab
aa35dc3c adcfdbde

+5 -2
+5 -2
drivers/media/platform/davinci/vpbe.c
··· 718 718 if (ret) { 719 719 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s", 720 720 def_output); 721 - return ret; 721 + goto fail_kfree_amp; 722 722 } 723 723 724 724 printk(KERN_NOTICE "Setting default mode to %s\n", def_mode); ··· 726 726 if (ret) { 727 727 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s", 728 728 def_mode); 729 - return ret; 729 + goto fail_kfree_amp; 730 730 } 731 731 vpbe_dev->initialized = 1; 732 732 /* TBD handling of bootargs for default output and mode */ 733 733 return 0; 734 734 735 + fail_kfree_amp: 736 + mutex_lock(&vpbe_dev->lock); 737 + kfree(vpbe_dev->amp); 735 738 fail_kfree_encoders: 736 739 kfree(vpbe_dev->encoders); 737 740 fail_dev_unregister: