summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2017-11-02 00:05:40 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-11 21:17:22 +0300
commit09db1a462a03a1177a768406451405e4e0dcaf9a (patch)
tree97d400e2ce6212ca717ad3e7cd9bf820cfec8b21
parenta9cb97c3e628902e37583d8a40bb28cf76522cf1 (diff)
downloadlinux-09db1a462a03a1177a768406451405e4e0dcaf9a.tar.xz
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: Mauro Carvalho Chehab <mchehab@s-opensource.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--include/linux/led-class-flash.h4
1 files changed, 4 insertions, 0 deletions
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);