Patch "hwmon: (adt7470) Prevent divide by zero in adt7470_fan_write()" has been added to the 5.16-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    hwmon: (adt7470) Prevent divide by zero in adt7470_fan_write()

to the 5.16-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hwmon-adt7470-prevent-divide-by-zero-in-adt7470_fan_.patch
and it can be found in the queue-5.16 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c4eb88d6023f55e38cfa8abd9bc9fe92143568b2
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Fri Jan 21 14:55:43 2022 +0300

    hwmon: (adt7470) Prevent divide by zero in adt7470_fan_write()
    
    [ Upstream commit c1ec0cabc36718efc7fe8b4157d41b82d08ec1d2 ]
    
    The "val" variable is controlled by the user and comes from
    hwmon_attr_store().  The FAN_RPM_TO_PERIOD() macro divides by "val"
    so a zero will crash the system.  Check for that and return -EINVAL.
    Negatives are also invalid so return -EINVAL for those too.
    
    Fixes: fc958a61ff6d ("hwmon: (adt7470) Convert to devm_hwmon_device_register_with_info API")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index d519aca4a9d64..fb6d14d213a18 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -662,6 +662,9 @@ static int adt7470_fan_write(struct device *dev, u32 attr, int channel, long val
 	struct adt7470_data *data = dev_get_drvdata(dev);
 	int err;
 
+	if (val <= 0)
+		return -EINVAL;
+
 	val = FAN_RPM_TO_PERIOD(val);
 	val = clamp_val(val, 1, 65534);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux