Skip to content

Commit 5c3ef39

Browse files
Uwe Kleine-Könightejun
authored andcommitted
ata: sata_mv: check for errors when parsing nr-ports from dt
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> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 6929ef3 commit 5c3ef39

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

drivers/ata/sata_mv.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4090,7 +4090,20 @@ static int mv_platform_probe(struct platform_device *pdev)
40904090

40914091
/* allocate host */
40924092
if (pdev->dev.of_node) {
4093-
of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports);
4093+
rc = of_property_read_u32(pdev->dev.of_node, "nr-ports",
4094+
&n_ports);
4095+
if (rc) {
4096+
dev_err(&pdev->dev,
4097+
"error parsing nr-ports property: %d\n", rc);
4098+
return rc;
4099+
}
4100+
4101+
if (n_ports <= 0) {
4102+
dev_err(&pdev->dev, "nr-ports must be positive: %d\n",
4103+
n_ports);
4104+
return -EINVAL;
4105+
}
4106+
40944107
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
40954108
} else {
40964109
mv_platform_data = dev_get_platdata(&pdev->dev);

0 commit comments

Comments
 (0)