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

ti-st: handle null allocation return correctly.

static analysis with smatch picked up the following error:

get_platform_data() error: potential null dereference 'dt_pdata'.
(kzalloc returns null)

Instead, the code should return NULL to avoid the following null
pointer deference. Also, remove the error message as it is
redundant, the caller emits an error message to alert of a
failure anyhow.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Colin Ian King and committed by
Greg Kroah-Hartman
0810f18f 4b6fda0b

+1 -2
+1 -2
drivers/misc/ti-st/st_kim.c
··· 752 752 int len; 753 753 754 754 dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL); 755 - 756 755 if (!dt_pdata) 757 - pr_err("Can't allocate device_tree platform data\n"); 756 + return NULL; 758 757 759 758 dt_property = of_get_property(np, "dev_name", &len); 760 759 if (dt_property)