Re: [PATCH v2 03/26] media: led-class-flash: better handle NULL flash struct

2017-11-02 Thread Sakari Ailus
Hi Mauro,

Somehow the To header in your message ends up being:

To: unlisted-recipients: no To-header on input <;

This doesn't end well when replying to the messages.

On Wed, Nov 01, 2017 at 05:05:40PM -0400, Mauro Carvalho Chehab wrote:
> The logic at V4L2 led core assumes that the flash struct
> can be null. However, it doesn't check for null while
> trying to set, causing some smatch  to warn:
> 
>   drivers/media/v4l2-core/v4l2-flash-led-class.c:210 v4l2_flash_s_ctrl() 
> error: we previously assumed 'fled_cdev' could be null (see line 200)

I guess this is fine for suppressing the warning but there's not a
technical problem it fixes: if there's no flash, then the flash controls
aren't registered with the control handler.

Anyway,

Acked-by: Sakari Ailus 

> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  include/linux/led-class-flash.h | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h
> index e97966d1fb8d..700efaa9e115 100644
> --- a/include/linux/led-class-flash.h
> +++ b/include/linux/led-class-flash.h
> @@ -121,6 +121,8 @@ extern void led_classdev_flash_unregister(struct 
> led_classdev_flash *fled_cdev);
>  static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
>   bool state)
>  {
> + if (!fled_cdev)
> + return -EINVAL;
>   return fled_cdev->ops->strobe_set(fled_cdev, state);
>  }
>  
> @@ -136,6 +138,8 @@ static inline int led_set_flash_strobe(struct 
> led_classdev_flash *fled_cdev,
>  static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev,
>   bool *state)
>  {
> + if (!fled_cdev)
> + return -EINVAL;
>   if (fled_cdev->ops->strobe_get)
>   return fled_cdev->ops->strobe_get(fled_cdev, state);
>  

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


[PATCH v2 03/26] media: led-class-flash: better handle NULL flash struct

2017-11-01 Thread Mauro Carvalho Chehab
The logic at V4L2 led core assumes that the flash struct
can be null. However, it doesn't check for null while
trying to set, causing some smatch  to warn:

drivers/media/v4l2-core/v4l2-flash-led-class.c:210 v4l2_flash_s_ctrl() 
error: we previously assumed 'fled_cdev' could be null (see line 200)

Signed-off-by: Mauro Carvalho Chehab 
---
 include/linux/led-class-flash.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h
index e97966d1fb8d..700efaa9e115 100644
--- a/include/linux/led-class-flash.h
+++ b/include/linux/led-class-flash.h
@@ -121,6 +121,8 @@ extern void led_classdev_flash_unregister(struct 
led_classdev_flash *fled_cdev);
 static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
bool state)
 {
+   if (!fled_cdev)
+   return -EINVAL;
return fled_cdev->ops->strobe_set(fled_cdev, state);
 }
 
@@ -136,6 +138,8 @@ static inline int led_set_flash_strobe(struct 
led_classdev_flash *fled_cdev,
 static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev,
bool *state)
 {
+   if (!fled_cdev)
+   return -EINVAL;
if (fled_cdev->ops->strobe_get)
return fled_cdev->ops->strobe_get(fled_cdev, state);
 
-- 
2.13.6