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

hwmon: (cros_ec) Fix access to restricted __le16

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>

authored by

Guenter Roeck and committed by
Tzung-Bi Shih
c8a4bdca 1f72dd04

+3 -2
+3 -2
drivers/hwmon/cros_ec_hwmon.c
··· 26 26 static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed) 27 27 { 28 28 int ret; 29 + __le16 __speed; 29 30 30 - ret = cros_ec_cmd_readmem(cros_ec, EC_MEMMAP_FAN + index * 2, 2, speed); 31 + ret = cros_ec_cmd_readmem(cros_ec, EC_MEMMAP_FAN + index * 2, 2, &__speed); 31 32 if (ret < 0) 32 33 return ret; 33 34 34 - *speed = le16_to_cpu(*speed); 35 + *speed = le16_to_cpu(__speed); 35 36 return 0; 36 37 } 37 38