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=1796380959; b=JDuq/QLeO0qn19xW1AHSJl3ADAS+nTuJ82ef49AE+w9rxplnRd2WZshpHFzDbbV+Jv4i LlTlamu6M3q3QzboJWTUJjpya6YLKIAUqu/d/R7OqR9jG4vKZvjhcW2t6FfOo7aMZ+liV qICMor0tb8Gibs3i44eJYfMelfb8kgY+gwAyPVWqrgVU8byQZoBbWsAkJz1faJdPu7+Y7 GUFGx3XkiZdsokDxis/Hr9D7jLcV2D0TpVzzOmvOdZRonCLRz8wMPFOfIHtc6pVC+3KqY iqYlmx9M6oeaYlTUo07KaTMnn5XtSJiWbyd5ql5ezVOcRPlf9YgKmazBOOl0Y4nutHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380959; 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=exjfswXuQBgSZwTpsOKmi5f3EGqIXXKbqQ7t2rowpeg=; b=Hs7BN/8esF+FArXb39E7ZHbJkXrcYNVb954OkwuGPRHWR32uERnnFaQuXnZljbl5zPBo K81ScigQopqZZJJXy87WiA/ADWTsrpNlnZa86DUWTW/16oLWT8V4rAT+YG8OMJQa0n0PG D9LflfFlLM9hidZxWVbVlaBnTN6DYRnCUC9J0vAqsa9VejbhalYwmLYqETkn3AF1htM5u P5TKlfRY0AEW2TSIUMXuKblO36aZSJeI+7waj75ZXArXgldN7xTQKVDy2WmT2miqcwxiY XrY+yq+PJYaBs9UPVCsR5ohrnlXpgrtEWv1xzAPco053qi+H/lwfbZldrXAkuYEmnjw== 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=dKicp3no; 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 D7933606A682; Fri, 4 Dec 2026 10:42:39 +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=dKicp3no Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55CDD1F000CE; Fri, 4 Dec 2026 10:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380959; bh=exjfswXuQBgSZwTpsOKmi5f3EGqIXXKbqQ7t2rowpeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dKicp3noK4YmzB9nB6vTicJd022TOszpUpCcEFLgAInltg2ixRj0ZGlIiJsyjdsaw 6wSX907O4Cp04Tl1bcPbqj8dN8HDk8by8YLWRV2FaXNECGdRKPbUSVy2iHpC24TcmK ynyLJlaFbbU1mfN3mCjVz7NJg0YuexcCdrMLnNj0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ziheng Wei , Guenter Roeck Subject: [PATCH 7.3 499/742] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Date: Fri, 4 Dec 2026 19:06:03 +0900 Message-ID: <20261204100648.394858294@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -1820,7 +1820,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; @@ -1874,7 +1874,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;