summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc/allocator
diff options
context:
space:
mode:
authorZiheng Wei <zihengw03@163.com>2026-11-15 16:02:01 +0800
committerGuenter Roeck <linux@roeck-us.net>2026-11-15 14:42:25 -0800
commit07571b42cf41d0e42fb890713340a8f0a3c03d56 (patch)
treeada7e8564022db8f5b4d3f33d6336aa0ef70b38e /rust/kernel/alloc/allocator
parent69624d7d821ec7d3f9801e86acf555a8edc82f99 (diff)
hwmon: (nct6775) Fix incorrect struct cast in beep callbacks
On big-endian architectures, writing the in[1-*]_beep, fan[1-*]_beep and temp[1-*]_beep sysfs attributes in the nct6775 hardware monitoring driver always changes channel 0 due to an incorrect struct downcast in the beep store callbacks. The driver defines these sysfs attributes using SENSOR_TEMPLATE(), which initializes them as struct sensor_device_attribute (where the index is a 32-bit int). However, the sysfs store callbacks nct6775_store_beep() and store_temp_beep() incorrectly downcast the attribute to a struct sensor_device_attribute_2 (where the index is an 8-bit u8). Because both structs start with struct device_attribute, container_of() resolves to the same base address. On big-endian architectures, reading the 8-bit index field from the memory layout of a 32-bit int fetches the most significant byte (which is 0), rather than the intended channel number. This type mismatch causes all beep writes to change the beep setting of channel 0, regardless of which channel the user targeted. Fix the type casts in the two store callbacks. Not runtime-tested: the only big-endian machine available to me (s390x under QEMU) cannot build the platform driver (no HAS_IOPORT). Fixes: 30846993047b ("hwmon: (nct6775) Add support for beep attributes") Cc: stable@vger.kernel.org Signed-off-by: Ziheng Wei <zihengw03@163.com> Link: https://patch.msgid.link/20261115080203.910033-2-zihengw03@163.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'rust/kernel/alloc/allocator')
0 files changed, 0 insertions, 0 deletions