[RFC v2 10/10] pseries/papr-hvpipe: Fix error handling in case of init routine fails

From: Ritesh Harjani (IBM)

Date: Wed Apr 08 2026 - 08:06:09 EST


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().

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>
---
arch/powerpc/platforms/pseries/papr-hvpipe.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/platforms/pseries/papr-hvpipe.c
index c708869ca732..b6d0b36915c6 100644
--- a/arch/powerpc/platforms/pseries/papr-hvpipe.c
+++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c
@@ -785,18 +785,20 @@ static int __init papr_hvpipe_init(void)
if (ret)
goto out_wq;

- ret = set_hvpipe_sys_param(1);
+ ret = misc_register(&papr_hvpipe_dev);
if (ret)
goto out_wq;

- ret = misc_register(&papr_hvpipe_dev);
+ ret = set_hvpipe_sys_param(1);
if (ret)
- goto out_wq;
+ 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:
--
2.39.5