mmc: sdhci-of-arasan: Add NULL check for data field
authorSai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
Thu, 12 May 2022 07:19:53 +0000 (12:49 +0530)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 16 May 2022 13:49:31 +0000 (15:49 +0200)
Add NULL check for data field retrieved from of_device_get_match_data()
before dereferencing the data.
Addresses-coverity: CID 305057:Dereference null return value (NULL_RETURNS)

Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/1652339993-27280-1-git-send-email-lakshmi.sai.krishna.potthuri@xilinx.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-of-arasan.c

index 6a2e5a468424672ee436853046470b76b72e6424..757801dfc30869d445914b8dc6f83e31a5c77dc0 100644 (file)
@@ -1577,6 +1577,9 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
        const struct sdhci_arasan_of_data *data;
 
        data = of_device_get_match_data(dev);
+       if (!data)
+               return -EINVAL;
+
        host = sdhci_pltfm_init(pdev, data->pdata, sizeof(*sdhci_arasan));
 
        if (IS_ERR(host))