mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Prajna Rajendra Kumar <prajna.rajendrakumar@microchip.com>,
	Conor Dooley <conor.dooley@microchip.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] spi: Fix potential uninitialized variable in probe()
Date: Fri, 21 Nov 2025 14:18:49 +0000	[thread overview]
Message-ID: <cd3dc38e-72f6-4e83-a67f-266523e686f1@sirena.org.uk> (raw)
In-Reply-To: <aSBqhdjiywXq2Aso@stanley.mountain>

[-- Attachment #1: Type: text/plain, Size: 1256 bytes --]

On Fri, Nov 21, 2025 at 04:35:01PM +0300, Dan Carpenter wrote:
> If the device tree is messed up, then potentially the "protocol" string
> could potentially be uninitialized.  Add a check to prevent that.
> 
> Fixes: 059f545832be ("spi: add support for microchip "soft" spi controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/spi/spi-microchip-core-spi.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/spi/spi-microchip-core-spi.c b/drivers/spi/spi-microchip-core-spi.c
> index b8738190cdcb..e65036cc62f3 100644
> --- a/drivers/spi/spi-microchip-core-spi.c
> +++ b/drivers/spi/spi-microchip-core-spi.c
> @@ -320,6 +320,8 @@ static int mchp_corespi_probe(struct platform_device *pdev)
>  	 */
>  	ret = of_property_read_string(pdev->dev.of_node, "microchip,protocol-configuration",
>  				      &protocol);
> +	if (ret)
> +		return ret;
>  	if (strcmp(protocol, "motorola") != 0)
>  		return dev_err_probe(&pdev->dev, -EINVAL,
>  				     "CoreSPI: protocol '%s' not supported by this driver\n",

This should probably also complain about not being able to get the
property, otherwise nobody is going to be able to figure out what's
wrong if we actually hit the error case.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2025-11-21 14:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 13:35 Dan Carpenter
2025-11-21 14:18 ` Mark Brown [this message]
2025-11-21 16:20   ` Conor Dooley
2025-11-24  7:56     ` Dan Carpenter

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=cd3dc38e-72f6-4e83-a67f-266523e686f1@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=dan.carpenter@linaro.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=prajna.rajendrakumar@microchip.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®