diff options
author | Tom Rix <trix@redhat.com> | 2022-03-01 05:52:23 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2022-04-04 11:19:01 +0300 |
commit | f50232193e61cf89a73130b5e843fef30763c428 (patch) | |
tree | 32dd70f076277f345c31424a5e46ac7e7774fb3a /drivers/iio/chemical/scd4x.c | |
parent | 460bfa65b0de72f4d8a808bc7cfb1cb591a95b18 (diff) | |
download | linux-f50232193e61cf89a73130b5e843fef30763c428.tar.xz |
iio: scd4x: check return of scd4x_write_and_fetch
Clang static analysis reports this problem
scd4x.c:474:10: warning: The left operand of '==' is a
garbage value
if (val == 0xff) {
~~~ ^
val is only set from a successful call to scd4x_write_and_fetch()
So check it's return.
Fixes: 49d22b695cbb ("drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor")
Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20220301025223.223223-1-trix@redhat.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/chemical/scd4x.c')
-rw-r--r-- | drivers/iio/chemical/scd4x.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c index 20d4e7584e92..37143b5526ee 100644 --- a/drivers/iio/chemical/scd4x.c +++ b/drivers/iio/chemical/scd4x.c @@ -471,12 +471,15 @@ static ssize_t calibration_forced_value_store(struct device *dev, ret = scd4x_write_and_fetch(state, CMD_FRC, arg, &val, sizeof(val)); mutex_unlock(&state->lock); + if (ret) + return ret; + if (val == 0xff) { dev_err(dev, "forced calibration has failed"); return -EINVAL; } - return ret ?: len; + return len; } static IIO_DEVICE_ATTR_RW(calibration_auto_enable, 0); |