diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2016-11-29 06:13:38 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2016-11-29 11:35:06 -0500 |
commit | 5c3ef39738f74a3759918cc1a1ad099504f9d1b7 (patch) | |
tree | a29d2bee4b6726435e743819dc4ef4b04f32d652 | |
parent | 6929ef385e09c0065b87fda3e7b872a5070ac783 (diff) |
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>
-rw-r--r-- | drivers/ata/sata_mv.c | 15 |
1 files changed, 14 insertions, 1 deletions
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) | |||
4090 | 4090 | ||
4091 | /* allocate host */ | 4091 | /* allocate host */ |
4092 | if (pdev->dev.of_node) { | 4092 | 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 | |||
4094 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | 4107 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); |
4095 | } else { | 4108 | } else { |
4096 | mv_platform_data = dev_get_platdata(&pdev->dev); | 4109 | mv_platform_data = dev_get_platdata(&pdev->dev); |