From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB57630FF30 for ; Fri, 13 Feb 2026 11:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.67.36.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770980778; cv=none; b=lfOna8goI0eljD7kIigOUC6sVu7dkGcGVtRxEt6Mjc0yB6naMmliM9Vtq+Vza4Hhp08PUWkv+OWa06PtGLBOGIsyXdTbAYFTfTKx43gKgx5ln/5s1w1ZtqjytacCllgolguCTZDbkFhhoCGd7Inqi9wkMyDmDfRemdD8Ca92F4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770980778; c=relaxed/simple; bh=T8C0kW3L8kfQ8lEZOMNDH8DIXhN49QbsDcqIXTGf1uU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LmAX4sby0pSsAqgZh0iKgV2Y8WcoUgBuQ5qAi1g/N83Mbrr/+GGjzU7qFhPZdgLx9ibzMqrZyKzhwg3VbdF3Nh3nF9SRAklQg0bre3JNvgtrcLHaEfQdMnTq50yO21U7ZgJ2R49amtrcNHY+aIqMZeeKjqaUP0mOIsDkEdUvxNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net; spf=pass smtp.mailfrom=posteo.net; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b=X2g2njXx; arc=none smtp.client-ip=185.67.36.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b="X2g2njXx" Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 10B0B240101 for ; Fri, 13 Feb 2026 12:00:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=2017; t=1770980421; bh=DkXQFRF6rnThdSPYfiSLSD241i5nICJqc3BVoN723YA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:From; b=X2g2njXx8+MMcA1akYv0HBbC7bzhH2RhKZOuCe4Y+A3rLk4Z4A3FGrb4CsD6yxekR PVqW9rTvuIrYzpxlhT8cU7yVFspBhPU9o9XUSMICBnqhU4VVsWoLqZFFsPeqqBHnlm 6Gm0Xk7T/Nus/kc93Ih5uAqxSEy2SYBUcw6TBpymXddppHDCa30iBQEEMg+oK+JfTr hvFFOGSD+1ZFAZBBg2O/e5PEqW0zjfFGQ6bKlXx8yGgacHRTOzeJxTP2V4LBdWfFkG oJPPxd0hbKT5BNziMjyetQIrTti1PwSJKUkTiwmkoQ0NECNAFW2VxWm2BEBgjupSI7 hloV7W8ny+HFw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4fC8Ml6gzsz9rxF; Fri, 13 Feb 2026 12:00:19 +0100 (CET) Date: Fri, 13 Feb 2026 11:00:20 +0000 From: =?utf-8?Q?J=2E_Neusch=C3=A4fer?= To: Felix Gu Cc: Mark Brown , 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() Message-ID: References: <20260212-wpcm-v1-1-5b7c4f526aac@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 > --- Seems reasonable. Reviewed-by: J. Neuschäfer 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 >