Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ti-ads1298: prevent divide by zero in ads1298_set_samp_freq()

The "val" variable comes from the user so we need to ensure that it's not
zero. In fact, all negative values are invalid as well. Add a check for
that.

Fixes: 00ef7708fa60 ("iio: adc: ti-ads1298: Add driver")
Acked-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/c32c9087-86de-423b-8101-67b4a7f9d728@moroto.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Dan Carpenter and committed by
Jonathan Cameron
df621530 debabbb1

+2
+2
drivers/iio/adc/ti-ads1298.c
··· 258 258 rate = ADS1298_CLK_RATE_HZ; 259 259 if (!rate) 260 260 return -EINVAL; 261 + if (val <= 0) 262 + return -EINVAL; 261 263 262 264 factor = (rate >> ADS1298_SHIFT_DR_HR) / val; 263 265 if (factor >= BIT(ADS1298_SHIFT_DR_LP))