Input: soc_button_array - add missing memory allocation check
authorPramod Gurav <pramod.gurav@smartplayin.com>
Sat, 26 Jul 2014 01:41:39 +0000 (18:41 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 26 Jul 2014 01:58:41 +0000 (18:58 -0700)
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/soc_button_array.c

index 5a6334b..e34dfc2 100644 (file)
@@ -83,6 +83,9 @@ soc_button_device_create(struct pnp_dev *pdev,
                                       sizeof(*gpio_keys_pdata) +
                                        sizeof(*gpio_keys) * MAX_NBUTTONS,
                                       GFP_KERNEL);
+       if (!gpio_keys_pdata)
+               return ERR_PTR(-ENOMEM);
+
        gpio_keys = (void *)(gpio_keys_pdata + 1);
 
        for (info = button_info; info->name; info++) {