public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Neuschäfer" <j.ne@posteo.net>
To: Felix Gu <ustc.gu@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	openbmc@lists.ozlabs.org, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: wpcm-fiu: Fix potential NULL pointer dereference in wpcm_fiu_probe()
Date: Fri, 13 Feb 2026 11:00:20 +0000	[thread overview]
Message-ID: <aY8EQ_7Oho-5BeM_@probook> (raw)
In-Reply-To: <20260212-wpcm-v1-1-5b7c4f526aac@gmail.com>

On Thu, Feb 12, 2026 at 08:41:40PM +0800, Felix Gu wrote:
> platform_get_resource_byname() can return NULL, which would cause a crash
> when passed the pointer to resource_size().
> 
> Move the fiu->memory_size assignment after the error check for
> devm_ioremap_resource() to prevent the potential NULL pointer dereference.
> 
> Fixes: 9838c182471e ("spi: wpcm-fiu: Add direct map support")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---

Seems reasonable.

Reviewed-by: J. Neuschäfer <j.ne@posteo.net>

Thanks!

>  drivers/spi/spi-wpcm-fiu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-wpcm-fiu.c b/drivers/spi/spi-wpcm-fiu.c
> index 0e3ee5516587..0e26ff178505 100644
> --- a/drivers/spi/spi-wpcm-fiu.c
> +++ b/drivers/spi/spi-wpcm-fiu.c
> @@ -459,11 +459,11 @@ static int wpcm_fiu_probe(struct platform_device *pdev)
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "memory");
>  	fiu->memory = devm_ioremap_resource(dev, res);
> -	fiu->memory_size = min_t(size_t, resource_size(res), MAX_MEMORY_SIZE_TOTAL);
>  	if (IS_ERR(fiu->memory))
>  		return dev_err_probe(dev, PTR_ERR(fiu->memory),
>  			       "Failed to map flash memory window\n");
>  
> +	fiu->memory_size = min_t(size_t, resource_size(res), MAX_MEMORY_SIZE_TOTAL);
>  	fiu->shm_regmap = syscon_regmap_lookup_by_phandle_optional(dev->of_node, "nuvoton,shm");
>  
>  	wpcm_fiu_hw_init(fiu);
> 
> ---
> base-commit: 9152bc8cebcb14dc16b03ec81f2377ee8ce12268
> change-id: 20260212-wpcm-d86f76761645
> 
> Best regards,
> -- 
> Felix Gu <ustc.gu@gmail.com>
> 

  parent reply	other threads:[~2026-02-13 11:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12 12:41 [PATCH] spi: wpcm-fiu: Fix potential NULL pointer dereference in wpcm_fiu_probe() Felix Gu
2026-02-13  8:54 ` Markus Elfring
2026-02-13 11:00 ` J. Neuschäfer [this message]
2026-02-16 18:08 ` Mark Brown

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=aY8EQ_7Oho-5BeM_@probook \
    --to=j.ne@posteo.net \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.org \
    --cc=ustc.gu@gmail.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