# Re: \[PATCH v2 1/6\] powerpc/xive: remove dead NULL check after GFP\_NOFAIL allocation

- From: Gou Hao \<hidden\>
- Date: 2026-07-27 03:13:20 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2026/07/17321728
- Thread: https://ratatoskr.run/linuxppc-dev/2026/07/17312811/t.md

```text
On 7/27/26 01:04, Cédric Le Goater wrote:
> As suggested by Andrew, let's change the approach and remove entirely
> __GFP_NOFAIL instead and make all xive_ipis access paths NULL-safe.

Yes, that's better.

> On 7/24/26 04:28, Gou Hao wrote:
>> kzalloc_objs with the __GFP_NOFAIL flag will never return NULL, so the
>> subsequent NULL check is unreachable dead code. Remove it.
>>
>> Signed-off-by: Gou Hao <redacted>
>> Reviewed-by: Wentao Guan <redacted>
>> Reviewed-by: jiazhenyuan <redacted>
>> ---
>>   arch/powerpc/sysdev/xive/common.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/ xive/common.c
>> index dadd1f46ec939..f2904a5c2b7bf 100644
>> --- a/arch/powerpc/sysdev/xive/common.c
>> +++ b/arch/powerpc/sysdev/xive/common.c
>> @@ -1134,9 +1134,6 @@ static int __init xive_init_ipis(void)
>>       xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids,
>>                    GFP_KERNEL | __GFP_NOFAIL);
>
> So let's remove __GFP_NOFAIL here.
>
>> -    if (!xive_ipis)
>> -        goto out_free_domain;
>> -
>
> Let's keep it now that allocation can really fail.
>
>>       for_each_node(node) {>           struct xive_ipi_desc *xid = &xive_ipis[node];
>>           struct xive_ipi_alloc_info info = { node };
>> @@ -1158,7 +1155,7 @@ static int __init xive_init_ipis(void)
>>   out_free_xive_ipis:
>>       kfree(xive_ipis);
>> -out_free_domain:
>
> and keep the out_free_domain label
>
>> +    xive_ipis = NULL;
>
> and yes we should add 'xive_ipis = NULL;'
>
>>       irq_domain_remove(ipi_domain);
>>   out_free_fwnode:
>>       irq_domain_free_fwnode(fwnode);
>
>
> The prepare_cpu() path is broken. To fix, we need to check xive_ipis
> is not NULL in xive_setup_cpu_ipi() and xive_cleanup_cpu_ipi(). It
> should be a straight forward local change. Nothing complex.
>
> You can test with QEMU. The pSeries and the PowerNV machines are well
> supported under emulation. Ping me if you need help.
>
Thank you for the review. I will fix these issues in the next version of the patch, and test locally.

-- 
Thanks,
Gou Hao


```
