[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220615113021.2493586-1-conor.dooley@microchip.com>
Date: Wed, 15 Jun 2022 12:30:22 +0100
From: Conor Dooley <conor.dooley@...rochip.com>
To: Mark Brown <broonie@...nel.org>
CC: Daire McNamara <daire.mcnamara@...rochip.com>,
Lewis Hanly <lewis.hanly@...rochip.com>,
Conor Dooley <conor.dooley@...rochip.com>,
<linux-riscv@...ts.infradead.org>, <linux-spi@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Dan Carpenter <dan.carpenter@...cle.com>
Subject: [PATCH] spi: microchip-core: fix passing zero to PTR_ERR warning
It is possible that the error case for devm_clk_get() returns NULL,
in which case zero will be passed to PTR_ERR() as shown by the Smatch
static checker warning:
drivers/spi/spi-microchip-core.c:557 mchp_corespi_probe()
warn: passing zero to 'PTR_ERR'
Fix the warning by explicitly returning an error if devm_clk_get()
returns NULL.
Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers")
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Link: https://lore.kernel.org/linux-spi/20220615091633.GI2168@kadam/
Signed-off-by: Conor Dooley <conor.dooley@...rochip.com>
---
drivers/spi/spi-microchip-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-core.c
index 5b2aee30fa04..d44663cca071 100644
--- a/drivers/spi/spi-microchip-core.c
+++ b/drivers/spi/spi-microchip-core.c
@@ -554,7 +554,7 @@ static int mchp_corespi_probe(struct platform_device *pdev)
spi->clk = devm_clk_get(&pdev->dev, NULL);
if (!spi->clk || IS_ERR(spi->clk)) {
- ret = PTR_ERR(spi->clk);
+ ret = !spi->clk ? -ENXIO : PTR_ERR(spi->clk);
dev_err(&pdev->dev, "could not get clk: %d\n", ret);
goto error_release_master;
}
--
2.36.1
Powered by blists - more mailing lists