memory: ti-aemif: fix a potential NULL-pointer dereference
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 6 Sep 2018 12:12:19 +0000 (14:12 +0200)
committerOlof Johansson <olof@lixom.net>
Thu, 6 Sep 2018 17:04:07 +0000 (10:04 -0700)
Platform data pointer may be NULL. We check it everywhere but in one
place. Fix it.

Fixes: 8af70cd2ca50 ("memory: aemif: add support for board files")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: stable@vger.kernel.org
Signed-off-by: Olof Johansson <olof@lixom.net>
drivers/memory/ti-aemif.c

index 31112f6..475e5b3 100644 (file)
@@ -411,7 +411,7 @@ static int aemif_probe(struct platform_device *pdev)
                        if (ret < 0)
                                goto error;
                }
-       } else {
+       } else if (pdata) {
                for (i = 0; i < pdata->num_sub_devices; i++) {
                        pdata->sub_devices[i].dev.parent = dev;
                        ret = platform_device_register(&pdata->sub_devices[i]);