]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: proximity: hx9023s: Protect against division by zero in set_samp_freq
authorYasin Lee <yasin.lee.x@gmail.com>
Fri, 13 Feb 2026 15:14:44 +0000 (23:14 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 08:24:38 +0000 (08:24 +0000)
Avoid division by zero when sampling frequency is unspecified.

Fixes: 60df548277b7 ("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>
drivers/iio/proximity/hx9023s.c

index ad839db6b326b1abca6897ec84215e28fa0c4be2..17e00ee2b6f84499d8595f135a8d70171456aae4 100644 (file)
@@ -719,6 +719,9 @@ static int hx9023s_set_samp_freq(struct hx9023s_data *data, int val, int val2)
        struct device *dev = regmap_get_device(data->regmap);
        unsigned int i, period_ms;
 
+       if (!val && !val2)
+               return -EINVAL;
+
        period_ms = div_u64(NANO, (val * MEGA + val2));
 
        for (i = 0; i < ARRAY_SIZE(hx9023s_samp_freq_table); i++) {