iio: st_sensors: handle memory allocation failure to fix null pointer dereference
authorColin Ian King <colin.king@canonical.com>
Tue, 21 Jan 2020 16:17:57 +0000 (16:17 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Fri, 14 Feb 2020 12:08:22 +0000 (12:08 +0000)
commit9960c70949d4356abed8747a20637e0946bb0bad
tree97d01373ca3f277f92508661ce22ee01c35cfe7f
parentcef2760954cf4f8228d14af9bd0b77a021979278
iio: st_sensors: handle memory allocation failure to fix null pointer dereference

A null pointer deference on pdata can occur if the allocation of
pdata fails.  Fix this by adding a null pointer check and handle
the -ENOMEM failure in the caller.

Addresses-Coverity: ("Dereference null return value")
Fixes: 3ce85cc4fbb7 ("iio: st_sensors: get platform data from device tree")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/common/st_sensors/st_sensors_core.c