]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ti-st: handle null allocation return correctly.
authorColin Ian King <colin.king@canonical.com>
Tue, 12 May 2015 21:37:23 +0000 (22:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 May 2015 19:16:47 +0000 (12:16 -0700)
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>
drivers/misc/ti-st/st_kim.c

index 18e7a03985d4cc601ecbbb511dc3665d217cce88..5027b8ffae4378e0aeda58513f993778bb34c30c 100644 (file)
@@ -752,9 +752,8 @@ static struct ti_st_plat_data *get_platform_data(struct device *dev)
        int len;
 
        dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL);
-
        if (!dt_pdata)
-               pr_err("Can't allocate device_tree platform data\n");
+               return NULL;
 
        dt_property = of_get_property(np, "dev_name", &len);
        if (dt_property)