mfd: wm831x: Fix possible NULL pointer dereference
authorJavier Martinez Canillas <javier@osg.samsung.com>
Mon, 14 Sep 2015 09:07:56 +0000 (11:07 +0200)
committerLee Jones <lee.jones@linaro.org>
Mon, 26 Oct 2015 14:49:04 +0000 (14:49 +0000)
The driver always checks for pdata being NULL except in one place.
Add a check to prevent a possible NULL pointer deference error.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/wm831x-core.c

index 28366a90e1adfbec14b5679244676b1077c9926e..3e0e99ec5836dafa758468351b000e76ad6b7dae 100644 (file)
@@ -1626,7 +1626,9 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
        mutex_init(&wm831x->io_lock);
        mutex_init(&wm831x->key_lock);
        dev_set_drvdata(wm831x->dev, wm831x);
-       wm831x->soft_shutdown = pdata->soft_shutdown;
+
+       if (pdata)
+               wm831x->soft_shutdown = pdata->soft_shutdown;
 
        ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
        if (ret < 0) {