]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pseries/papr-hvpipe: Fix & simplify error handling in papr_hvpipe_init()
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>
Fri, 1 May 2026 04:11:43 +0000 (09:41 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Wed, 6 May 2026 02:00:24 +0000 (07:30 +0530)
Remove such 3 levels of nesting patterns to check success return values
from function calls.

ret = enable_hvpipe_IRQ()
    if (!ret)
    ret = set_hvpipe_sys_param(1)
        if (!ret)
    ret = misc_register()

Instead just bail out to "out*:" labels, in case of any error. This
simplifies the init flow.

While at it let's also fix the following error handling logic:
We have already enabled interrupt sources and enabled hvpipe to received
interrupts, if misc_register() fails, we will destroy the workqueue, but
the HMC might send us a msg via hvpipe which will call, queue work on
the workqueue which might be destroyed.

So instead, let's reverse the order of enabling set_hvpipe_sys_param(1)
and in case of an error let's remove the misc dev by calling
misc_deregister().

Cc: stable@vger.kernel.org
Fixes: 39a08a4f94980 ("powerpc/pseries: Enable hvpipe with ibm,set-system-parameter RTAS")
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/f2141eafb80e7780395e03aa9a22e8a37be80513.1777606826.git.ritesh.list@gmail.com
arch/powerpc/platforms/pseries/papr-hvpipe.c

index 402781299497a52b16787cd60c23ec1622d02a7a..800649f309a573e8269ea8de76a3689737a07c42 100644 (file)
@@ -780,23 +780,29 @@ static int __init papr_hvpipe_init(void)
        }
 
        ret = enable_hvpipe_IRQ();
-       if (!ret) {
-               ret = set_hvpipe_sys_param(1);
-               if (!ret)
-                       ret = misc_register(&papr_hvpipe_dev);
-       }
+       if (ret)
+               goto out_wq;
 
-       if (!ret) {
-               pr_info("hvpipe feature is enabled\n");
-               hvpipe_feature = true;
-               return 0;
-       }
+       ret = misc_register(&papr_hvpipe_dev);
+       if (ret)
+               goto out_wq;
 
-       pr_err("hvpipe feature is not enabled %d\n", ret);
+       ret = set_hvpipe_sys_param(1);
+       if (ret)
+               goto out_misc;
+
+       pr_info("hvpipe feature is enabled\n");
+       hvpipe_feature = true;
+       return 0;
+
+out_misc:
+       misc_deregister(&papr_hvpipe_dev);
+out_wq:
        destroy_workqueue(papr_hvpipe_wq);
 out:
        kfree(papr_hvpipe_work);
        papr_hvpipe_work = NULL;
+       pr_err("hvpipe feature is not enabled %d\n", ret);
        return ret;
 }
 machine_device_initcall(pseries, papr_hvpipe_init);