mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Gou Hao <gouhao@uniontech.com>,
	maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
	chleroy@kernel.org, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com,
	simona@ffwll.ch, bharat@chelsio.com, jgg@ziepe.ca,
	leon@kernel.org, akpm@linux-foundation.org, namcao@linutronix.de,
	ynorov@nvidia.com, sshegde@linux.ibm.com, nilay@linux.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org,
	linux-mm@kvack.org, gouhaojake@163.com, kernel@uniontech.com
Subject: Re: [PATCH v2 1/6] powerpc/xive: remove dead NULL check after GFP_NOFAIL allocation
Date: Sun, 26 Jul 2026 19:04:25 +0200	[thread overview]
Message-ID: <3fba3c54-ea4f-449c-8cd3-f24c516bb31d@kaod.org> (raw)
In-Reply-To: <20260724022851.466017-2-gouhao@uniontech.com>

As suggested by Andrew, let's change the approach and remove entirely
__GFP_NOFAIL instead and make all xive_ipis access paths NULL-safe.
   
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 <gouhao@uniontech.com>
> Reviewed-by: Wentao Guan <guanwentao@uniontech.com>
> Reviewed-by: jiazhenyuan <jiazhenyuan@uniontech.com>
> ---
>   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.

Thanks,

C.





  parent reply	other threads:[~2026-07-26 17:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  2:28 [PATCH v2 0/6] remove dead NULL checks after GFP_NOFAIL allocations and fix xive use-after-free Gou Hao
2026-07-24  2:28 ` [PATCH v2 1/6] powerpc/xive: remove dead NULL check after GFP_NOFAIL allocation Gou Hao
2026-07-24  4:55   ` Cédric Le Goater
2026-07-26 17:04   ` Cédric Le Goater [this message]
2026-07-27  3:11     ` Gou Hao
2026-07-27  6:16   ` Mukesh Kumar Chaurasiya
2026-07-24  2:28 ` [PATCH v2 2/6] powerpc/xive: add error return value to xive_smp_probe() Gou Hao
2026-07-24  4:55   ` Cédric Le Goater
2026-07-24  2:28 ` [PATCH v2 3/6] powerpc/xive: fix use-after-free of xive_ipis Gou Hao
2026-07-24  4:58   ` Cédric Le Goater
2026-07-26 16:57   ` Cédric Le Goater
2026-07-24  2:28 ` [PATCH v2 4/6] drm: remove dead WARN_ON NULL check after GFP_NOFAIL allocation Gou Hao
2026-07-24  2:28 ` [PATCH v2 5/6] lib/test_hmm: remove dead NULL checks after GFP_NOFAIL allocations Gou Hao
2026-07-27  1:41   ` Alistair Popple
2026-07-24  2:28 ` [PATCH v2 6/6] RDMA/cxgb4: " Gou Hao
2026-07-24  7:34   ` Potnuri Bharat Teja
2026-07-26  3:26 ` [PATCH v2 0/6] remove dead NULL checks after GFP_NOFAIL allocations and fix xive use-after-free Andrew Morton
2026-07-26  8:24   ` Leon Romanovsky
2026-07-26  8:23 ` (subset) " Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3fba3c54-ea4f-449c-8cd3-f24c516bb31d@kaod.org \
    --to=clg@kaod.org \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bharat@chelsio.com \
    --cc=chleroy@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gouhao@uniontech.com \
    --cc=gouhaojake@163.com \
    --cc=jgg@ziepe.ca \
    --cc=kernel@uniontech.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=mripard@kernel.org \
    --cc=namcao@linutronix.de \
    --cc=nilay@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=sshegde@linux.ibm.com \
    --cc=tzimmermann@suse.de \
    --cc=ynorov@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®