]> git.baikalelectronics.ru Git - kernel.git/commit
iio: chemical: sunrise_co2: set val parameter only on success
authorTom Rix <trix@redhat.com>
Fri, 24 Dec 2021 15:08:33 +0000 (07:08 -0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 28 Dec 2021 18:37:41 +0000 (18:37 +0000)
commit78293933af56293cd0da028f597401a0de7a72d9
tree640bf9147be8a20c07bc4f90a47a8764f7e8f2e8
parent9670daeec857768a11a0a55501f5aba2c393c0d0
iio: chemical: sunrise_co2: set val parameter only on success

Clang static analysis reports this representative warning

sunrise_co2.c:410:9: warning: Assigned value is garbage or undefined
  *val = value;
       ^ ~~~~~

The ealier call to sunrise_read_word can fail without setting
value.  So defer setting val until we know the read was successful.

Fixes: 4eab0ad66949 ("iio: chemical: Add Senseair Sunrise 006-0-007 driver")
Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20211224150833.3278236-1-trix@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/chemical/sunrise_co2.c