From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389308; b=3scbRo8ugo1uJQb98Xvy+l+roWe1piZ+Gm++RzJnGE+7TjCgBLnqHzuHdCGmxjsfhutf xJvfEVSkH4BSbjD8mbuhfU8oDMZMoLiAX98udiMYdjksfNBXljui+G9aPpzTWfs79rX5U wl8q1nMmKPOZrkT+Cr1KZ13oCQSpJtTvVehzI0ORDuzYew33yB7tFsn7pens9nlQ394ah wLIlI8enhYN3zF7z/4BZeutMp1R2hNoQ3coIwF5mzZ/xVmoQOAEiRYIBhZ5DIMXJbDlUY BUVp+q5piVStiLnrhP8udulVcJ+5fdWXU7bL6kQ0d2ck76La5PwpDdS2ywjblmZzYQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389308; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=lcZ0YGxoyhfJyVaio+ncXcQ7Rn+tu4NdJ81Qr7egpeg=; b=zKD8YQQQ9OAcHCZ5TYIgCa6xQL+lSZ3ncjGpV8zCXOVQdHhXrP7rG74hlHwc324dX7BI TbLoKcmtNsKmVNB5E6xAJHrpx6lHMqlhhJVu0o1UpMbnfZ50KLv4vrv39EORi9ufWtdNo FTk8FWFiLbAYZMGi2XW7ntWLpssvPwkCJHIVaxoAUX7omaVoMxMIMiJHssC3Ms9P+4Cq6 1cHdd1wNC6O9eE3aWBVp5Zs2prPk8sK1sD+raHVRiwp2Hcaq8FhNPVh+06HuXw4tmrx/I 9SU9RvX+aaMVVkUfbjyl9Th5ysqhwGTFQnjmKPdY6diOmn9JaBZfp5yfBGDn9wuARcw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j7na57VG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 758A3606A322; Fri, 4 Dec 2026 13:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j7na57VG Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF7061F00897; Fri, 4 Dec 2026 13:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389308; bh=lcZ0YGxoyhfJyVaio+ncXcQ7Rn+tu4NdJ81Qr7egpeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j7na57VG2zeEsRrsgFzB5alBR2UAk97bBhOh4AUubCLweTXme6saTWDmVFAIy32N6 iQWvrvCovOgUM2xHnVOTEabXveBJpHmj3kH2JRKFb37ia/1KusgYXH/RLw3NdbwQJO iBg54PL7X0uiXtkNl6mj2akOCuu9A8nOWTP39WDI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ziheng Wei , Guenter Roeck Subject: [PATCH 6.1 0944/1059] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Date: Fri, 4 Dec 2026 19:07:55 +0900 Message-ID: <20261204100708.474009633@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ziheng Wei commit 07571b42cf41d0e42fb890713340a8f0a3c03d56 upstream. 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 Link: https://patch.msgid.link/20261115080203.910033-2-zihengw03@163.com Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/nct6775-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/hwmon/nct6775-core.c +++ b/drivers/hwmon/nct6775-core.c @@ -1818,7 +1818,7 @@ EXPORT_SYMBOL_GPL(nct6775_show_beep); ssize_t nct6775_store_beep(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); struct nct6775_data *data = dev_get_drvdata(dev); int nr = data->BEEP_BITS[sattr->index]; int regindex = nr >> 3; @@ -1872,7 +1872,7 @@ static ssize_t store_temp_beep(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); struct nct6775_data *data = dev_get_drvdata(dev); int nr, bit, regindex; unsigned long val;