Unverified Commit cb99656b authored by Dan Carpenter's avatar Dan Carpenter Committed by Mark Brown
Browse files

spi: Fix potential uninitialized variable in probe()



If the device tree is messed up, then potentially the "protocol" string
could potentially be uninitialized.  The property is supposed to default
to "motorola" so if the of_property_read_string() function returns
-EINVAL then default to "motorola".

Fixes: 059f5458 ("spi: add support for microchip "soft" spi controller")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarPrajna Rajendra Kumar <prajna.rajendrakumar@microchip.com>
Link: https://patch.msgid.link/aSQPkfkiJ0w-FJMW@stanley.mountain


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 43a3adb6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -295,10 +295,10 @@ static int mchp_corespi_transfer_one(struct spi_controller *host,

static int mchp_corespi_probe(struct platform_device *pdev)
{
	const char *protocol = "motorola";
	struct spi_controller *host;
	struct mchp_corespi *spi;
	struct resource *res;
	const char *protocol;
	u32 num_cs, mode, frame_size;
	bool assert_ssel;
	int ret = 0;
@@ -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 && ret != -EINVAL)
		return dev_err_probe(&pdev->dev, ret, "Error reading protocol-configuration\n");
	if (strcmp(protocol, "motorola") != 0)
		return dev_err_probe(&pdev->dev, -EINVAL,
				     "CoreSPI: protocol '%s' not supported by this driver\n",