]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (cros_ec) Fix access to restricted __le16
authorGuenter Roeck <linux@roeck-us.net>
Thu, 6 Jun 2024 18:05:07 +0000 (11:05 -0700)
committerTzung-Bi Shih <tzungbi@kernel.org>
Fri, 7 Jun 2024 09:59:58 +0000 (09:59 +0000)
0-day complains:

drivers-hwmon-cros_ec_hwmon.c:sparse:sparse:cast-to-restricted-__le16

Fix by using a __le16 typed variable as parameter to le16_to_cpu().

Fixes: bc3e45258096 ("hwmon: add ChromeOS EC driver")
Cc: Thomas Weißschuh <linux@weissschuh.net>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240606180507.3332237-1-linux@roeck-us.net
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/hwmon/cros_ec_hwmon.c

index b3ba7247e06b2b16018cef6bf6330f1b6cf23cf4..5514cf780b8beab272670d6591ed298ddac5afbf 100644 (file)
@@ -26,12 +26,13 @@ struct cros_ec_hwmon_priv {
 static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed)
 {
        int ret;
+       __le16 __speed;
 
-       ret = cros_ec_cmd_readmem(cros_ec, EC_MEMMAP_FAN + index * 2, 2, speed);
+       ret = cros_ec_cmd_readmem(cros_ec, EC_MEMMAP_FAN + index * 2, 2, &__speed);
        if (ret < 0)
                return ret;
 
-       *speed = le16_to_cpu(*speed);
+       *speed = le16_to_cpu(__speed);
        return 0;
 }