From: Meng Li <[email protected]>

When build kernel, there is a warning as below:
warning: label 'err_put_device' defined but not used [-Wunused-label]
 1220 | err_put_device:
      | ^~~~~~~~~~~~~~
Detailed reason as below:
The sdk commit 07ab84bb864d("firmware: stratix10-svc: extend
svc to support FCS features ") introduce FCS feature. It causes confilt
when merging upstream commit d99247f9b542("firmware: stratix10-svc:
Fix a resource leak in an error handling path "). So, correct the error
processing path to correct code, not only fix building warning.

Signed-off-by: Meng Li <[email protected]>
---
 drivers/firmware/stratix10-svc.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index d874c13d364e..3ade34034960 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1194,22 +1194,19 @@ 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;
-       }
+       if (ret)
+               goto err_put_device;
 
        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_del_device;
        }
 
        ret = platform_device_add(svc->intel_svc_fcs);
-       if (ret) {
-               platform_device_put(svc->intel_svc_fcs);
-               return ret;
-       }
+       if (ret)
+               goto err_del_device;
 
        dev_set_drvdata(dev, svc);
 
@@ -1217,8 +1214,14 @@ static int stratix10_svc_drv_probe(struct 
platform_device *pdev)
 
        return 0;
 
+err_del_device:
+       platform_device_del(svc->stratix10_svc_rsu);
+
 err_put_device:
        platform_device_put(svc->stratix10_svc_rsu);
+       if (svc->intel_svc_fcs)
+               platform_device_put(svc->intel_svc_fcs);
+
 err_free_kfifo:
        kfifo_free(&controller->svc_fifo);
        return ret;
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#10329): 
https://lists.yoctoproject.org/g/linux-yocto/message/10329
Mute This Topic: https://lists.yoctoproject.org/mt/85131312/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to