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

mfd: wm831x-spi: Add NULL check before pointer dereference

Add NULL check before dereferencing pointer of_id in order to avoid
a potential NULL pointer dereference.

Addresses-Coverity-ID: 1408830
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Gustavo A. R. Silva and committed by
Lee Jones
7b55033f 800e5455

+4
+4
drivers/mfd/wm831x-spi.c
··· 34 34 35 35 if (spi->dev.of_node) { 36 36 of_id = of_match_device(wm831x_of_match, &spi->dev); 37 + if (!of_id) { 38 + dev_err(&spi->dev, "Failed to match device\n"); 39 + return -ENODEV; 40 + } 37 41 type = (enum wm831x_parent)of_id->data; 38 42 } else { 39 43 type = (enum wm831x_parent)id->driver_data;