Skip to contentSkip to conversation

spi: sifive: check return value for platform_get_resource()

PATCH New Aurabindo Jayamohanan 1 participant 1 message Sep 17, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: sifive: check return value for platform_get_resource()

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

---
 drivers/spi/spi-sifive.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/spi/spi-sifive.c +6 -0
index 93ec2c6cdbfd..67485067a694 100644
@@ -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);
Signature · 1 line
2.23.0