Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: wmt-sdmmc: Fix NULL pointer dereference

'of_id' is dereferenced before NULL pointer check. Move it to
after the check.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Tony Prisk <linux@prisktech.co.nz>
Signed-off-by: Chris Ball <chris@printf.net>

authored by

Sachin Kamat and committed by
Chris Ball
43aaa50f c4c7fb19

+3 -1
+3 -1
drivers/mmc/host/wmt-sdmmc.c
··· 757 757 struct device_node *np = pdev->dev.of_node; 758 758 const struct of_device_id *of_id = 759 759 of_match_device(wmt_mci_dt_ids, &pdev->dev); 760 - const struct wmt_mci_caps *wmt_caps = of_id->data; 760 + const struct wmt_mci_caps *wmt_caps; 761 761 int ret; 762 762 int regular_irq, dma_irq; 763 763 ··· 765 765 dev_err(&pdev->dev, "Controller capabilities data missing\n"); 766 766 return -EFAULT; 767 767 } 768 + 769 + wmt_caps = of_id->data; 768 770 769 771 if (!np) { 770 772 dev_err(&pdev->dev, "Missing SDMMC description in devicetree\n");