Skip to content

Commit a318cfc

Browse files
yasinleexjic23
authored andcommitted
iio: proximity: hx9023s: Protect against division by zero in set_samp_freq
Avoid division by zero when sampling frequency is unspecified. Fixes: 60df548 ("iio: proximity: Add driver support for TYHX's HX9023S capacitive proximity sensor") Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 585b90c commit a318cfc

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/iio/proximity/hx9023s.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ static int hx9023s_set_samp_freq(struct hx9023s_data *data, int val, int val2)
719719
struct device *dev = regmap_get_device(data->regmap);
720720
unsigned int i, period_ms;
721721

722+
if (!val && !val2)
723+
return -EINVAL;
724+
722725
period_ms = div_u64(NANO, (val * MEGA + val2));
723726

724727
for (i = 0; i < ARRAY_SIZE(hx9023s_samp_freq_table); i++) {

0 commit comments

Comments
 (0)