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>
 
        /* 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);