# \[PATCH\] powerpc/xive: Fix error handling when allocating an IPI

- Subsystems: LINUX FOR POWERPC (32-BIT AND 64-BIT), THE REST
- Maintainers: Madhavan Srinivasan, Linus Torvalds
- Status: LANDED (3f601608b71c · 2021-07-05 12:23)
- Landed in mainline as 3f601608b71c on 2021-07-05.
- List: linuxppc-dev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linuxppc-dev/2021/07/6880727/t

## \[PATCH\] powerpc/xive: Fix error handling when allocating an IPI

- From: Cédric Le Goater \<clg@kaod.org\>
- Date: 2021-07-01 15:24:39 
- Message: https://ratatoskr.run/linuxppc-dev/2021/07/6880727.md

```text
This is a smatch warning:

  arch/powerpc/sysdev/xive/common.c:1161 xive_request_ipi() warn: unsigned 'xid->irq' is never less than zero.

Fixes: fd6db2892eba ("powerpc/xive: Modernize XIVE-IPI domain with an 'alloc' handler")
Cc: <redacted> # v5.13
Reported-by: kernel test robot <redacted>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/sysdev/xive/common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index f8ff558bc305..7bbb9bc83057 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1148,11 +1148,10 @@ static int __init xive_request_ipi(void)
 		 * Since the HW interrupt number doesn't have any meaning,
 		 * simply use the node number.
 		 */
-		xid->irq = irq_domain_alloc_irqs(ipi_domain, 1, node, &info);
-		if (xid->irq < 0) {
-			ret = xid->irq;
+		ret = irq_domain_alloc_irqs(ipi_domain, 1, node, &info);
+		if (ret < 0)
 			goto out_free_xive_ipis;
-		}
+		xid->irq = ret;
 
 		snprintf(xid->name, sizeof(xid->name), "IPI-%d", node);
 
-- 
2.31.1

```

## Re: \[PATCH\] powerpc/xive: Fix error handling when allocating an IPI

- From: Michael Ellerman \<hidden\>
- Date: 2021-07-06 10:53:09 
- Message: https://ratatoskr.run/linuxppc-dev/2021/07/9523552.md

```text
On Thu, 1 Jul 2021 17:24:12 +0200, Cédric Le Goater wrote:
> This is a smatch warning:
> 
>   arch/powerpc/sysdev/xive/common.c:1161 xive_request_ipi() warn: unsigned 'xid->irq' is never less than zero.

Applied to powerpc/fixes.

[1/1] powerpc/xive: Fix error handling when allocating an IPI
      https://git.kernel.org/powerpc/c/3f601608b71c3ca1e199898cd16f09d707fedb56

cheers
```
