Skip to contentSkip to conversation

FAILED: patch "[PATCH] hwmon: (scmi) Check channel config allocation" failed to apply to 5.15-stable tree

PATCH Applied [email protected] 3 participants 3 messages Nov 25 – Nov 27

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x a2996d892d0150d059d39c683d95d6fd7a37630a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112550-overfeed-putt-7fcf@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a2996d892d0150d059d39c683d95d6fd7a37630a Mon Sep 17 00:00:00 2001
From: Sudeep Holla <[email protected]>
Date: Mon, 9 Nov 2026 15:19:26 +0000
Subject: [PATCH] hwmon: (scmi) Check channel config allocation

scmi_hwmon_add_chan_info() can fail to allocate a channel's config array. Ignoring that error leaves a channel with a NULL config pointer in the hwmon chip info, which hwmon dereferences while registering the device.

Check the helper's return value and abort probe on failure.

drivers/hwmon/scmi-hwmon.c +7 -5
index 7789285b6c67..0c82d8dbd626 100644
@@ -228,8 +228,8 @@ static int scmi_thermal_sensor_register(struct device *dev,
 
 static int scmi_hwmon_probe(struct scmi_device *sdev)
 {
-	int i, idx;
 	u16 nr_sensors;
+	int i, idx, ret;
 	enum hwmon_sensor_types type;
 	struct scmi_sensors *scmi_sensors;
 	const struct scmi_sensor_info *sensor;
@@ -297,8 +297,12 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
 		if (!nr_count[type])
 			continue;
 
-		scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev, nr_count[type],
-					 type, hwmon_attributes[type]);
+		ret = scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev,
+					       nr_count[type], type,
+					       hwmon_attributes[type]);
+		if (ret)
+			return ret;
+
 		*ptr_scmi_ci++ = scmi_hwmon_chan++;
 
 		scmi_sensors->info[type] =
@@ -333,8 +337,6 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
 		return PTR_ERR(hwdev);
 
 	for (i = 0; i < nr_count_temp; i++) {
-		int ret;
-
 		sensor = *(scmi_sensors->info[hwmon_temp] + i);
 		if (!sensor)
 			continue;
maintainer
#1 lore raw

PATCH 1/1 hwmon: (scmi) Check channel config allocation

scmi_hwmon_add_chan_info() can fail to allocate a channel's config array. Ignoring that error leaves a channel with a NULL config pointer in the hwmon chip info, which hwmon dereferences while registering the device.

Check the helper's return value and abort probe on failure.

Fixes b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI")
(cherry picked from commit a2996d892d0150d059d39c683d95d6fd7a37630a)
---
 drivers/hwmon/scmi-hwmon.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/hwmon/scmi-hwmon.c +7 -3
index b1329a58ce40..c263434d9e0b 100644
@@ -159,8 +159,8 @@ static u32 hwmon_attributes[hwmon_max] = {
 
 static int scmi_hwmon_probe(struct scmi_device *sdev)
 {
-	int i, idx;
 	u16 nr_sensors;
+	int i, idx, ret;
 	enum hwmon_sensor_types type;
 	struct scmi_sensors *scmi_sensors;
 	const struct scmi_sensor_info *sensor;
@@ -230,8 +230,12 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
 		if (!nr_count[type])
 			continue;
 
-		scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev, nr_count[type],
-					 type, hwmon_attributes[type]);
+		ret = scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev,
+					       nr_count[type], type,
+					       hwmon_attributes[type]);
+		if (ret)
+			return ret;
+
 		*ptr_scmi_ci++ = scmi_hwmon_chan++;
 
 		scmi_sensors->info[type] =
Signature · 1 line
2.43.0
maintainer Applied
#2 lore raw

Re: [PATCH 5.15.y] hwmon: (scmi) Check channel config allocation

Quoted 2 lines

scmi_hwmon_add_chan_info() can fail to allocate a channel's config array.

Queued for 5.15 and 5.10, thanks.

Signature · 2 lines
Thanks,
Sasha