* [PATCH] ata: sata_mv: check for errors when parsing nr-ports from dt
@ 2016-11-29 11:13 Uwe Kleine-König
2016-11-29 16:36 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2016-11-29 11:13 UTC (permalink / raw)
To: Tejun Heo; +Cc: linux-ide, kernel
If the nr-ports property is missing ata_host_alloc_pinfo is called with
n_ports = 0. This results in host->ports[0] = NULL which later makes
mv_init_host() oops when dereferencing this pointer.
Instead be a bit more cooperative and fail the probing with an error
message.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/ata/sata_mv.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index efc48bf89d51..823e938c9a78 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4090,7 +4090,20 @@ static int mv_platform_probe(struct platform_device *pdev)
/* allocate host */
if (pdev->dev.of_node) {
- of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports);
+ rc = of_property_read_u32(pdev->dev.of_node, "nr-ports",
+ &n_ports);
+ if (rc) {
+ dev_err(&pdev->dev,
+ "error parsing nr-ports property: %d\n", rc);
+ return rc;
+ }
+
+ if (n_ports <= 0) {
+ dev_err(&pdev->dev, "nr-ports must be positive: %d\n",
+ n_ports);
+ return -EINVAL;
+ }
+
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
} else {
mv_platform_data = dev_get_platdata(&pdev->dev);
--
2.10.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-29 16:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29 11:13 [PATCH] ata: sata_mv: check for errors when parsing nr-ports from dt Uwe Kleine-König
2016-11-29 16:36 ` Tejun Heo
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).