linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: sifive: check return value for platform_get_resource()
@ 2019-09-17  9:12 Aurabindo Jayamohanan
  2019-09-17  9:18 ` Paul Walmsley
  2019-09-17  9:23 ` Baolin Wang
  0 siblings, 2 replies; 11+ messages in thread
From: Aurabindo Jayamohanan @ 2019-09-17  9:12 UTC (permalink / raw)
  To: broonie, palmer, paul.walmsley; +Cc: linux-spi, linux-riscv, linux-kernel

platform_get_resource() may return NULL. If it is so, return -ENXIO

Signed-off-by: Aurabindo Jayamohanan <mail@aurabindo.in>
---
 drivers/spi/spi-sifive.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
index 93ec2c6cdbfd..67485067a694 100644
--- a/drivers/spi/spi-sifive.c
+++ b/drivers/spi/spi-sifive.c
@@ -308,6 +308,12 @@ static int sifive_spi_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "no IOMEM resource found\n");
+		ret = -ENXIO;
+		goto put_master;
+	}
+
 	spi->regs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(spi->regs)) {
 		ret = PTR_ERR(spi->regs);
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH] spi: sifive: check return value for platform_get_resource()
@ 2019-09-17  9:12 Aurabindo Jayamohanan
  0 siblings, 0 replies; 11+ messages in thread
From: Aurabindo Jayamohanan @ 2019-09-17  9:12 UTC (permalink / raw)
  To: broonie, palmer, paul.walmsley; +Cc: linux-spi, linux-riscv, linux-kernel

platform_get_resource() may return NULL. If it is so, return -ENXIO

Signed-off-by: Aurabindo Jayamohanan <mail@aurabindo.in>
---
 drivers/spi/spi-sifive.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
index 93ec2c6cdbfd..67485067a694 100644
--- a/drivers/spi/spi-sifive.c
+++ b/drivers/spi/spi-sifive.c
@@ -308,6 +308,12 @@ static int sifive_spi_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "no IOMEM resource found\n");
+		ret = -ENXIO;
+		goto put_master;
+	}
+
 	spi->regs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(spi->regs)) {
 		ret = PTR_ERR(spi->regs);
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-09-17 17:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-17  9:12 [PATCH] spi: sifive: check return value for platform_get_resource() Aurabindo Jayamohanan
2019-09-17  9:18 ` Paul Walmsley
2019-09-17  9:23 ` Baolin Wang
2019-09-17  9:58   ` Aurabindo Jayamohanan
2019-09-17 12:15   ` Paul Walmsley
2019-09-17 13:07     ` Geert Uytterhoeven
2019-09-17 14:06     ` Aurabindo Jayamohanan
2019-09-17 14:11       ` Paul Walmsley
2019-09-17 15:21         ` Paul Walmsley
2019-09-17 17:13           ` Aurabindo Jayamohanan
  -- strict thread matches above, loose matches on Subject: below --
2019-09-17  9:12 Aurabindo Jayamohanan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).