Skip to content

Commit f502321

Browse files
Tom Rixjic23
authored andcommitted
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: 49d22b6 ("drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor") Signed-off-by: Tom Rix <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 460bfa6 commit f502321

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/iio/chemical/scd4x.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,15 @@ static ssize_t calibration_forced_value_store(struct device *dev,
471471
ret = scd4x_write_and_fetch(state, CMD_FRC, arg, &val, sizeof(val));
472472
mutex_unlock(&state->lock);
473473

474+
if (ret)
475+
return ret;
476+
474477
if (val == 0xff) {
475478
dev_err(dev, "forced calibration has failed");
476479
return -EINVAL;
477480
}
478481

479-
return ret ?: len;
482+
return len;
480483
}
481484

482485
static IIO_DEVICE_ATTR_RW(calibration_auto_enable, 0);

0 commit comments

Comments
 (0)