* [PATCH 0/2] firmware: stratix10-svc: fix error handle in stratix10_svc_drv_probe()
@ 2022-11-03 7:09 Yang Yingliang
2022-11-03 7:09 ` [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() " Yang Yingliang
2022-11-03 7:09 ` [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Yang Yingliang
0 siblings, 2 replies; 6+ messages in thread
From: Yang Yingliang @ 2022-11-03 7:09 UTC (permalink / raw)
To: linux-kernel, dinguyen, richard.gong, atull, tien.sung.ang
This patchset fixes two error handle problems in error path in
stratix10_svc_drv_probe(). They are introduced by different commits.
Yang Yingliang (2):
firmware: stratix10-svc: add missing gen_pool_destroy() in
stratix10_svc_drv_probe()
firmware: stratix10-svc: fix error handle while alloc/add device
failed
drivers/firmware/stratix10-svc.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() in stratix10_svc_drv_probe()
2022-11-03 7:09 [PATCH 0/2] firmware: stratix10-svc: fix error handle in stratix10_svc_drv_probe() Yang Yingliang
@ 2022-11-03 7:09 ` Yang Yingliang
2022-11-07 19:56 ` Dinh Nguyen
2022-11-03 7:09 ` [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Yang Yingliang
1 sibling, 1 reply; 6+ messages in thread
From: Yang Yingliang @ 2022-11-03 7:09 UTC (permalink / raw)
To: linux-kernel, dinguyen, richard.gong, atull, tien.sung.ang
In error path in stratix10_svc_drv_probe(), gen_pool_destroy() should be called
to destroy the memory pool that created by svc_create_memory_pool().
Fixes: 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/firmware/stratix10-svc.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index b4081f4d88a3..1a5640b3ab42 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1138,13 +1138,17 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
/* allocate service controller and supporting channel */
controller = devm_kzalloc(dev, sizeof(*controller), GFP_KERNEL);
- if (!controller)
- return -ENOMEM;
+ if (!controller) {
+ ret = -ENOMEM;
+ goto err_destroy_pool;
+ }
chans = devm_kmalloc_array(dev, SVC_NUM_CHANNEL,
sizeof(*chans), GFP_KERNEL | __GFP_ZERO);
- if (!chans)
- return -ENOMEM;
+ if (!chans) {
+ ret = -ENOMEM;
+ goto err_destroy_pool;
+ }
controller->dev = dev;
controller->num_chans = SVC_NUM_CHANNEL;
@@ -1159,7 +1163,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
ret = kfifo_alloc(&controller->svc_fifo, fifo_size, GFP_KERNEL);
if (ret) {
dev_err(dev, "failed to allocate FIFO\n");
- return ret;
+ goto err_destroy_pool;
}
spin_lock_init(&controller->svc_fifo_lock);
@@ -1221,6 +1225,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
err_free_kfifo:
kfifo_free(&controller->svc_fifo);
+err_destroy_pool:
+ gen_pool_destroy(genpool);
return ret;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed
2022-11-03 7:09 [PATCH 0/2] firmware: stratix10-svc: fix error handle in stratix10_svc_drv_probe() Yang Yingliang
2022-11-03 7:09 ` [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() " Yang Yingliang
@ 2022-11-03 7:09 ` Yang Yingliang
2022-11-07 19:56 ` Dinh Nguyen
1 sibling, 1 reply; 6+ messages in thread
From: Yang Yingliang @ 2022-11-03 7:09 UTC (permalink / raw)
To: linux-kernel, dinguyen, richard.gong, atull, tien.sung.ang
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: e6281c26674e ("firmware: stratix10-svc: Add support for FCS")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/firmware/stratix10-svc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 1a5640b3ab42..bde1f543f529 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1202,19 +1202,20 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
ret = platform_device_add(svc->stratix10_svc_rsu);
if (ret) {
platform_device_put(svc->stratix10_svc_rsu);
- return ret;
+ goto err_free_kfifo;
}
svc->intel_svc_fcs = platform_device_alloc(INTEL_FCS, 1);
if (!svc->intel_svc_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);
if (ret) {
platform_device_put(svc->intel_svc_fcs);
- return ret;
+ goto err_unregister_dev;
}
dev_set_drvdata(dev, svc);
@@ -1223,6 +1224,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
return 0;
+err_unregister_dev:
+ platform_device_unregister(svc->stratix10_svc_rsu);
err_free_kfifo:
kfifo_free(&controller->svc_fifo);
err_destroy_pool:
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() in stratix10_svc_drv_probe()
2022-11-03 7:09 ` [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() " Yang Yingliang
@ 2022-11-07 19:56 ` Dinh Nguyen
0 siblings, 0 replies; 6+ messages in thread
From: Dinh Nguyen @ 2022-11-07 19:56 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, richard.gong, atull, tien.sung.ang
On 11/3/22 02:09, Yang Yingliang wrote:
> In error path in stratix10_svc_drv_probe(), gen_pool_destroy() should be called
> to destroy the memory pool that created by svc_create_memory_pool().
>
> Fixes: 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/firmware/stratix10-svc.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
> index b4081f4d88a3..1a5640b3ab42 100644
> --- a/drivers/firmware/stratix10-svc.c
> +++ b/drivers/firmware/stratix10-svc.c
> @@ -1138,13 +1138,17 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
>
> /* allocate service controller and supporting channel */
> controller = devm_kzalloc(dev, sizeof(*controller), GFP_KERNEL);
> - if (!controller)
> - return -ENOMEM;
> + if (!controller) {
> + ret = -ENOMEM;
> + goto err_destroy_pool;
> + }
>
> chans = devm_kmalloc_array(dev, SVC_NUM_CHANNEL,
> sizeof(*chans), GFP_KERNEL | __GFP_ZERO);
> - if (!chans)
> - return -ENOMEM;
> + if (!chans) {
> + ret = -ENOMEM;
> + goto err_destroy_pool;
> + }
>
> controller->dev = dev;
> controller->num_chans = SVC_NUM_CHANNEL;
> @@ -1159,7 +1163,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
> ret = kfifo_alloc(&controller->svc_fifo, fifo_size, GFP_KERNEL);
> if (ret) {
> dev_err(dev, "failed to allocate FIFO\n");
> - return ret;
> + goto err_destroy_pool;
> }
> spin_lock_init(&controller->svc_fifo_lock);
>
> @@ -1221,6 +1225,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
>
> err_free_kfifo:
> kfifo_free(&controller->svc_fifo);
> +err_destroy_pool:
> + gen_pool_destroy(genpool);
> return ret;
> }
>
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed
2022-11-03 7:09 ` [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Yang Yingliang
@ 2022-11-07 19:56 ` Dinh Nguyen
0 siblings, 0 replies; 6+ messages in thread
From: Dinh Nguyen @ 2022-11-07 19:56 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, richard.gong, atull, tien.sung.ang
On 11/3/22 02:09, Yang Yingliang wrote:
> 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: e6281c26674e ("firmware: stratix10-svc: Add support for FCS")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/firmware/stratix10-svc.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
> index 1a5640b3ab42..bde1f543f529 100644
> --- a/drivers/firmware/stratix10-svc.c
> +++ b/drivers/firmware/stratix10-svc.c
> @@ -1202,19 +1202,20 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
> ret = platform_device_add(svc->stratix10_svc_rsu);
> if (ret) {
> platform_device_put(svc->stratix10_svc_rsu);
> - return ret;
> + goto err_free_kfifo;
> }
>
> svc->intel_svc_fcs = platform_device_alloc(INTEL_FCS, 1);
> if (!svc->intel_svc_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);
> if (ret) {
> platform_device_put(svc->intel_svc_fcs);
> - return ret;
> + goto err_unregister_dev;
> }
>
> dev_set_drvdata(dev, svc);
> @@ -1223,6 +1224,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
>
> return 0;
>
> +err_unregister_dev:
> + platform_device_unregister(svc->stratix10_svc_rsu);
> err_free_kfifo:
> kfifo_free(&controller->svc_fifo);
> err_destroy_pool:
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed
2022-11-29 16:36 [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() in stratix10_svc_drv_probe() Dinh Nguyen
@ 2022-11-29 16:36 ` Dinh Nguyen
0 siblings, 0 replies; 6+ messages in thread
From: Dinh Nguyen @ 2022-11-29 16:36 UTC (permalink / raw)
To: gregkh; +Cc: dinguyen, linux-kernel, Yang Yingliang
From: Yang Yingliang <yangyingliang@huawei.com>
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: e6281c26674e ("firmware: stratix10-svc: Add support for FCS")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
drivers/firmware/stratix10-svc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 1a5640b3ab42..bde1f543f529 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1202,19 +1202,20 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
ret = platform_device_add(svc->stratix10_svc_rsu);
if (ret) {
platform_device_put(svc->stratix10_svc_rsu);
- return ret;
+ goto err_free_kfifo;
}
svc->intel_svc_fcs = platform_device_alloc(INTEL_FCS, 1);
if (!svc->intel_svc_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);
if (ret) {
platform_device_put(svc->intel_svc_fcs);
- return ret;
+ goto err_unregister_dev;
}
dev_set_drvdata(dev, svc);
@@ -1223,6 +1224,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
return 0;
+err_unregister_dev:
+ platform_device_unregister(svc->stratix10_svc_rsu);
err_free_kfifo:
kfifo_free(&controller->svc_fifo);
err_destroy_pool:
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-29 16:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 7:09 [PATCH 0/2] firmware: stratix10-svc: fix error handle in stratix10_svc_drv_probe() Yang Yingliang
2022-11-03 7:09 ` [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() " Yang Yingliang
2022-11-07 19:56 ` Dinh Nguyen
2022-11-03 7:09 ` [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Yang Yingliang
2022-11-07 19:56 ` Dinh Nguyen
2022-11-29 16:36 [PATCH 1/2] firmware: stratix10-svc: add missing gen_pool_destroy() in stratix10_svc_drv_probe() Dinh Nguyen
2022-11-29 16:36 ` [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Dinh Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).