staging: greybus: light: check delay_{on|off} before use
authorRui Miguel Silva <rmfrfs@gmail.com>
Fri, 30 Sep 2016 18:24:33 +0000 (19:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 2 Oct 2016 13:49:26 +0000 (15:49 +0200)
Even though we trust leds core that the pointers should be valid, we are
safer to check delay_{on|off} before use.

Also, this avoid a smatch warning:
drivers/staging/greybus/light.c:484 gb_blink_set()
warn: variable dereferenced before check 'delay_on' (see line 476)

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/light.c

index f3cd48521af054cd4302b8937aae28378307b527..80dc4a9d9a0e9f2a8bc4a5250eae8a3e49e9b772 100644 (file)
@@ -463,6 +463,9 @@ static int gb_blink_set(struct led_classdev *cdev, unsigned long *delay_on,
        if (channel->releasing)
                return -ESHUTDOWN;
 
+       if (!delay_on || !delay_off)
+               return -EINVAL;
+
        mutex_lock(&channel->lock);
        ret = gb_pm_runtime_get_sync(bundle);
        if (ret < 0)