summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYuan Can <yuancan@huawei.com>2022-11-11 06:09:26 +0000
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-11-25 07:38:16 +0000
commit6b8c5e4bec981a95cf8d7375286710f0e95b49cd (patch)
treec4a57b5d1711661b3875750cdf929319d445852b /drivers
parent48ecee615983cf4b191a53b32770fb550cd63b68 (diff)
downloadlinux-6b8c5e4bec981a95cf8d7375286710f0e95b49cd.tar.bz2
media: amphion: Fix error handling in vpu_driver_init()
A problem about modprobe amphion-vpu failed is triggered with the following log given: [ 2208.634841] Error: Driver 'amphion-vpu' is already registered, aborting... modprobe: ERROR: could not insert 'amphion_vpu': Device or resource busy The reason is that vpu_driver_init() returns vpu_core_driver_init() directly without checking its return value, if vpu_core_driver_init() failed, it returns without unregister amphion_vpu_driver, resulting the amphion-vpu can never be installed later. A simple call graph is shown as below: vpu_driver_init() platform_driver_register() # register amphion_vpu_driver vpu_core_driver_init() platform_driver_register() driver_register() bus_add_driver() dev = kzalloc(...) # OOM happened # return without unregister amphion_vpu_driver Fix by unregister amphion_vpu_driver when vpu_core_driver_init() returns error. Fixes: b50a64fc54af ("media: amphion: add amphion vpu device driver") Signed-off-by: Yuan Can <yuancan@huawei.com> Reviewed-by: ming_qian <ming.qian@nxp.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/platform/amphion/vpu_drv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/media/platform/amphion/vpu_drv.c b/drivers/media/platform/amphion/vpu_drv.c
index 9d5a5075343d..f01ce49d27e8 100644
--- a/drivers/media/platform/amphion/vpu_drv.c
+++ b/drivers/media/platform/amphion/vpu_drv.c
@@ -245,7 +245,11 @@ static int __init vpu_driver_init(void)
if (ret)
return ret;
- return vpu_core_driver_init();
+ ret = vpu_core_driver_init();
+ if (ret)
+ platform_driver_unregister(&amphion_vpu_driver);
+
+ return ret;
}
static void __exit vpu_driver_exit(void)