提交 09db1a46 编写于 作者: M Mauro Carvalho Chehab

media: led-class-flash: better handle NULL flash struct

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: NMauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: NSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
上级 a9cb97c3
...@@ -121,6 +121,8 @@ extern void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev); ...@@ -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, static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
bool state) bool state)
{ {
if (!fled_cdev)
return -EINVAL;
return fled_cdev->ops->strobe_set(fled_cdev, state); 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, ...@@ -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, static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev,
bool *state) bool *state)
{ {
if (!fled_cdev)
return -EINVAL;
if (fled_cdev->ops->strobe_get) if (fled_cdev->ops->strobe_get)
return fled_cdev->ops->strobe_get(fled_cdev, state); return fled_cdev->ops->strobe_get(fled_cdev, state);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册