led: gpio: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
[linux-2.6-microblaze.git] / drivers / leds / leds-gpio-register.c
index fbd8934..75717ba 100644 (file)
@@ -28,6 +28,9 @@ struct platform_device *__init gpio_led_register_device(
        struct platform_device *ret;
        struct gpio_led_platform_data _pdata = *pdata;
 
+       if (!pdata->num_leds)
+               return ERR_PTR(-EINVAL);
+
        _pdata.leds = kmemdup(pdata->leds,
                        pdata->num_leds * sizeof(*pdata->leds), GFP_KERNEL);
        if (!_pdata.leds)