Re: [PATCH v2 3/3] staging: greybus: light: check delay_{on|off} before use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 30, 2016 at 11:54 PM, Rui Miguel Silva <rmfrfs@xxxxxxxxx> wrote:
> Even though we trust leds core that the pointers should be valid, we are
> safer to check delay_{on|off} before use.

As these routines are getting called from core, I am not sure if it will
be right to have such checks.

Though, I saw the core code after writing above and the core doesn't check
these at all :)

> 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@xxxxxxxxx>
> ---
>  drivers/staging/greybus/light.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index f3cd485..80dc4a9 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -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)

Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux