mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Conor Dooley <conor.dooley@microchip.com>
To: Mark Brown <broonie@kernel.org>
Cc: Daire McNamara <daire.mcnamara@microchip.com>,
	Lewis Hanly <lewis.hanly@microchip.com>,
	Conor Dooley <conor.dooley@microchip.com>,
	<linux-riscv@lists.infradead.org>, <linux-spi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH] spi: microchip-core: fix passing zero to PTR_ERR warning
Date: Wed, 15 Jun 2022 12:30:22 +0100	[thread overview]
Message-ID: <20220615113021.2493586-1-conor.dooley@microchip.com> (raw)

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@oracle.com>
Link: https://lore.kernel.org/linux-spi/20220615091633.GI2168@kadam/
Signed-off-by: Conor Dooley <conor.dooley@microchip.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


             reply	other threads:[~2022-06-15 11:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 11:30 Conor Dooley [this message]
2022-06-15 11:40 ` Mark Brown
2022-06-15 11:57   ` Conor.Dooley
2022-06-15 12:37     ` Mark Brown
2022-06-15 12:42       ` Conor.Dooley
2022-06-15 12:49         ` Mark Brown
2022-06-15 12:51           ` Conor.Dooley

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=20220615113021.2493586-1-conor.dooley@microchip.com \
    --to=conor.dooley@microchip.com \
    --cc=broonie@kernel.org \
    --cc=daire.mcnamara@microchip.com \
    --cc=dan.carpenter@oracle.com \
    --cc=lewis.hanly@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    /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®