]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Mar 2026 15:15:31 +0000 (16:15 +0100)
commit a318cfc0853706f1d6ce682dba660bc455d674ef upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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++) {