Commit d66a4c20 authored by Yang Yingliang's avatar Yang Yingliang Committed by Greg Kroah-Hartman

firmware: stratix10-svc: fix error handle while alloc/add device failed

If add device "stratix10-rsu" failed in stratix10_svc_drv_probe(),
the 'svc_fifo' and 'genpool' need be freed in the error path.

If allocate or add device "intel-fcs" failed in stratix10_svc_drv_probe(),
the device "stratix10-rsu" need be unregistered in the error path.

Fixes: e6281c26 ("firmware: stratix10-svc: Add support for FCS")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarDinh Nguyen <dinguyen@kernel.org>
Link: https://lore.kernel.org/r/20221129163602.462369-2-dinguyen@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9175ee1a
...@@ -1202,19 +1202,20 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) ...@@ -1202,19 +1202,20 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
ret = platform_device_add(svc->stratix10_svc_rsu); ret = platform_device_add(svc->stratix10_svc_rsu);
if (ret) { if (ret) {
platform_device_put(svc->stratix10_svc_rsu); platform_device_put(svc->stratix10_svc_rsu);
return ret; goto err_free_kfifo;
} }
svc->intel_svc_fcs = platform_device_alloc(INTEL_FCS, 1); svc->intel_svc_fcs = platform_device_alloc(INTEL_FCS, 1);
if (!svc->intel_svc_fcs) { if (!svc->intel_svc_fcs) {
dev_err(dev, "failed to allocate %s device\n", INTEL_FCS); dev_err(dev, "failed to allocate %s device\n", INTEL_FCS);
return -ENOMEM; ret = -ENOMEM;
goto err_unregister_dev;
} }
ret = platform_device_add(svc->intel_svc_fcs); ret = platform_device_add(svc->intel_svc_fcs);
if (ret) { if (ret) {
platform_device_put(svc->intel_svc_fcs); platform_device_put(svc->intel_svc_fcs);
return ret; goto err_unregister_dev;
} }
dev_set_drvdata(dev, svc); dev_set_drvdata(dev, svc);
...@@ -1223,6 +1224,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) ...@@ -1223,6 +1224,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
return 0; return 0;
err_unregister_dev:
platform_device_unregister(svc->stratix10_svc_rsu);
err_free_kfifo: err_free_kfifo:
kfifo_free(&controller->svc_fifo); kfifo_free(&controller->svc_fifo);
err_destroy_pool: err_destroy_pool:
......
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