thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference
Zhang Rui
reviewerPATCH 1/1 thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference
When the hwmon device node of a thermal zone device is not found, using hwmon->device causes a kernel NULL pointer dereference.
---
dec07d399cc8 is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +1 -1
@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );return ; }
Signature · 1 line
2.25.1
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.
Actually it reverts the work done to encapsulate the thermal zone device structure.
Quoted 9 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0
drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 232
Quoted 5 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );
As it 'Should never happen', I would replace that by:
if (WARN_ON(!hwmon)) /* Should never happen... */ return;
Quoted 3 lines
drivers/thermal/thermal_hwmon.c +0
-0return ; }
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Rafael J. Wysocki
maintainerQuoted 32 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Actually it reverts the work done to encapsulate the thermal zone device structure.
Quoted 9 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 232
Quoted 5 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );As it 'Should never happen', I would replace that by:
Quoted 4 lines
if (WARN_ON(!hwmon))
/* Should never happen... */
return;Or just use pr_debug() instead of dev_dbg().
Quoted 4 lines
Quoted 4 lines
drivers/thermal/thermal_hwmon.c +0
-0return ; }
Zhang, Rui
reviewerQuoted 36 lines · Daniel Lezcano
Quoted 10 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermalzone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Actually it reverts the work done to encapsulate the thermal zone device
structure.Quoted 10 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct · line 234
Quoted 7 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n"); + dev_dbg(&tz->device,"hwmon device lookup failed!\n" );As it 'Should never happen', I would replace that by:
Quoted 3 lines
if (WARN_ON(!hwmon)) /* Should never happen... */ return;
Actually, the comment is wrong.
For thermal zones with tzp->no_hwmon set, this is always true.
We should add an extra check for that.
thanks,
rui
Rafael J. Wysocki
maintainerQuoted 42 lines · Rui
Quoted 36 lines · Daniel Lezcano
Quoted 10 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermalzone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Actually it reverts the work done to encapsulate the thermal zone device
structure.Quoted 10 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct · line 234
Quoted 7 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n"); + dev_dbg(&tz->device,"hwmon device lookup failed!\n" );As it 'Should never happen', I would replace that by:
Quoted 3 lines
if (WARN_ON(!hwmon)) /* Should never happen... */ return;
Quoted 5 lines
Actually, the comment is wrong.
For thermal zones with
tzp->no_hwmonset, this is always true.We should add an extra check for that.
OK, can you please send a patch fixing all this mess?
Rafael J. Wysocki
maintainerQuoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.
Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
At least this particular bug could be avoided this way.
Quoted 34 lines
Quoted 9 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 232
Quoted 5 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );As it 'Should never happen', I would replace that by:
if (WARN_ON(!hwmon)) /* Should never happen... */ return;drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 235
Quoted 3 lines
drivers/thermal/thermal_hwmon.c +0
-0return ; }--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Zhang, Rui
reviewerQuoted 19 lines · Rafael J. Wysocki
Quoted 13 lines · Daniel Lezcano
Quoted 11 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internalthermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo.
I'm not sure if the Fix tag applies to such commit or not.Quoted 3 lines
Actually it reverts the work done to encapsulate the thermal zone device
structure.
Quoted 6 lines
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
At least this particular bug could be avoided this way.
I didn't see your email before sending patch v2.
are we going to rework the previous series from Daniel thus patch v2 is no longer needed?
thanks,
rui
Quoted 40 lines
Quoted 40 lines
Quoted 11 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct · line 235
Quoted 8 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n"); + dev_dbg(&tz->device,"hwmon device lookup failed!\n");As it 'Should never happen', I would replace that by:
if (WARN_ON(!hwmon)) /* Should never happen... */ return;Quoted 3 lines
return; }--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Rafael J. Wysocki
maintainerQuoted 26 lines · Rui
Quoted 24 lines · Rafael J. Wysocki
Quoted 13 lines · Daniel Lezcano
Quoted 11 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internalthermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo.
I'm not sure if the Fix tag applies to such commit or not.Quoted 3 lines
Actually it reverts the work done to encapsulate the thermal zone device
structure.So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
Quoted 6 lines
Quoted 1 line
At least this particular bug could be avoided this way.
I didn't see your email before sending patch v2.
are we going to rework the previous series from Daniel thus patch v2 is no longer needed?
Well, let's see what Daniel says..
In any case, though, it is not very useful to carry an obvious NULL pointer dereference in linux-next and the pr_debug() statement added by the v2 can be replaced later, so I think I'll apply it.
Quoted 17 lines · Rafael J. Wysocki
Quoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
Quoted 6 lines
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
At least this particular bug could be avoided this way.
Actually we previously said the thermal_hwmon can be considered as part of the thermal core code, so we can keep using tz->device.
I'll drop this change from the series.
On the other side, adding more thermal_zone_debug/info.. gives opportunities to external components of the core thermal framework to write thermal zone device related message. I'm not sure that is a good thing, each writer should stay in its namespace, no ?
Quoted 34 lines
Quoted 34 lines
Quoted 9 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 232
Quoted 5 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );As it 'Should never happen', I would replace that by:
if (WARN_ON(!hwmon)) /* Should never happen... */ return;drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 235
Quoted 3 lines
drivers/thermal/thermal_hwmon.c +0
-0return ; }--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Rafael J. Wysocki
maintainerQuoted 24 lines · Daniel Lezcano
Quoted 22 lines · Rafael J. Wysocki
Quoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
Quoted 6 lines
Quoted 1 line
At least this particular bug could be avoided this way.
Actually we previously said the
thermal_hwmoncan be considered as part of the thermal core code, so we can keep usingtz->device.I'll drop this change from the series.
But it's there in my thermal branch already.
Do you want to revert the thermal_hwmon.c part of commit dec07d399cc8?
Quoted 4 lines
On the other side, adding more thermal_zone_debug/info.. gives opportunities to external components of the core thermal framework to write thermal zone device related message. I'm not sure that is a good thing, each writer should stay in its namespace, no ?
IMV whoever is allowed to use a thermal zone pointer should also be allowed to print messages related to its use, especially debug ones.
"Encapsulation" means that the members of a thermal zone device object should not be accessed directly by its users other than the core, not that it cannot be used as a message tag.
Quoted 28 lines · Rafael J. Wysocki
Quoted 26 lines · Daniel Lezcano
Quoted 23 lines · Rafael J. Wysocki
Quoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
At least this particular bug could be avoided this way.
Quoted 8 lines
Quoted 4 lines
Actually we previously said the
thermal_hwmoncan be considered as part of the thermal core code, so we can keep usingtz->device.I'll drop this change from the series.
But it's there in my thermal branch already.
Do you want to revert the
thermal_hwmon.cpart of commitdec07d399cc8?
Oh, right. Fair enough.
I think Rui's patch is fine then.
Quoted 11 lines
Quoted 4 lines
On the other side, adding more thermal_zone_debug/info.. gives opportunities to external components of the core thermal framework to write thermal zone device related message. I'm not sure that is a good thing, each writer should stay in its namespace, no ?
IMV whoever is allowed to use a thermal zone pointer should also be allowed to print messages related to its use, especially debug ones.
"Encapsulation" means that the members of a thermal zone device object should not be accessed directly by its users other than the core, not that it cannot be used as a message tag.
Actually it is not about the encapsulation but the namespace of the messages. If a driver has an issue, IMO it is better it uses the device related messages and let thermal zone messages to be related to what is happening in the thermal framework, not in the back end.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Rafael J. Wysocki
maintainerQuoted 35 lines · Daniel Lezcano
Quoted 33 lines · Rafael J. Wysocki
Quoted 30 lines · Daniel Lezcano
Quoted 17 lines · Rafael J. Wysocki
Quoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
Quoted 6 lines
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
At least this particular bug could be avoided this way.
Actually we previously said the
thermal_hwmoncan be considered as part of the thermal core code, so we can keep usingtz->device.I'll drop this change from the series.
Quoted 7 lines
Quoted 3 lines
But it's there in my thermal branch already.
Do you want to revert the
thermal_hwmon.cpart of commitdec07d399cc8?Oh, right. Fair enough.
I think Rui's patch is fine then.
I guess you mean the $subject one, that is:
https://patchwork.kernel.org/project/linux-pm/patch/[email protected]
What about the message printed when temp is NULL. Should the original form of it be restored too?
Quoted 26 lines
Quoted 11 lines
Quoted 4 lines
On the other side, adding more thermal_zone_debug/info.. gives opportunities to external components of the core thermal framework to write thermal zone device related message. I'm not sure that is a good thing, each writer should stay in its namespace, no ?
IMV whoever is allowed to use a thermal zone pointer should also be allowed to print messages related to its use, especially debug ones.
"Encapsulation" means that the members of a thermal zone device object should not be accessed directly by its users other than the core, not that it cannot be used as a message tag.
Actually it is not about the encapsulation but the namespace of the messages. If a driver has an issue, IMO it is better it uses the device related messages and let thermal zone messages to be related to what is happening in the thermal framework, not in the back end.
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Quoted 41 lines · Rafael J. Wysocki
Quoted 39 lines · Daniel Lezcano
Quoted 36 lines · Rafael J. Wysocki
Quoted 24 lines · Daniel Lezcano
Quoted 22 lines · Rafael J. Wysocki
Quoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
Quoted 6 lines
Quoted 1 line
At least this particular bug could be avoided this way.
Actually we previously said the
thermal_hwmoncan be considered as part of the thermal core code, so we can keep usingtz->device.I'll drop this change from the series.
But it's there in my thermal branch already.
Do you want to revert the
thermal_hwmon.cpart of commitdec07d399cc8?
Quoted 7 lines
Quoted 3 lines
Oh, right. Fair enough.
I think Rui's patch is fine then.
I guess you mean the $subject one, that is:
https://patchwork.kernel.org/project/linux-pm/patch/[email protected]
Correct
Quoted 2 lines
What about the message printed when temp is NULL. Should the original form of it be restored too?
Yes, you are right, for the sake of consistency we should restore also this one.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 50 lines · CEST Daniel Lezcano
Quoted 41 lines · Rafael J. Wysocki
Quoted 39 lines · Daniel Lezcano
Quoted 36 lines · Rafael J. Wysocki
Quoted 24 lines · Daniel Lezcano
Quoted 22 lines · Rafael J. Wysocki
Quoted 12 lines · Daniel Lezcano
Quoted 9 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.Quoted 2 lines
Actually it reverts the work done to encapsulate the thermal zone device structure.
So maybe instead of the wholesale switch to using "driver-specific" device pointers for printing messages, something like thermal_zone_debug/info/warn/error() taking a thermal zone pointer as the first argument can be defined?
Quoted 6 lines
Quoted 1 line
At least this particular bug could be avoided this way.
Actually we previously said the
thermal_hwmoncan be considered as part of the thermal core code, so we can keep usingtz->device.I'll drop this change from the series.
But it's there in my thermal branch already.
Do you want to revert the
thermal_hwmon.cpart of commitdec07d399cc8?Quoted 7 lines
Quoted 3 lines
Oh, right. Fair enough.
I think Rui's patch is fine then.
I guess you mean the $subject one, that is:
https://patchwork.kernel.org/project/linux-pm/patch/[email protected]
Quoted 7 lines
Correct
Quoted 2 lines
What about the message printed when temp is NULL. Should the original form of it be restored too?
Yes, you are right, for the sake of consistency we should restore also this one.
So I'm going to apply the appended patch.
Please let me know if there are any concerns regarding it.
---
From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] thermal: thermal_hwmon: Revert recent message adjustment
For the sake of consistency, revert the second part of the thermal_hwmon.c hunk from commit dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field") after the first part of it has been reverted.
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +1 -1
@@ -236,7 +236,7 @@ void thermal_remove_hwmon_sysfs(struct t temp =thermal_hwmon_lookup_temp (hwmon, tz);if (unlikely (!temp)) {/* Should never happen... */ -dev_dbg (hwmon->device,"temperature input lookup failed!\n" ); +dev_dbg (&tz->device,"temperature input lookup failed!\n" );return ; }
Daniel Lezcano
Acked-byOn 29/03/2023 19:43, Rafael J. Wysocki wrote:
[ ... ]
Quoted 14 lines
Quoted 5 lines
Quoted 2 lines
What about the message printed when temp is NULL. Should the original form of it be restored too?
Yes, you are right, for the sake of consistency we should restore also this one.
So I'm going to apply the appended patch.
Please let me know if there are any concerns regarding it.
---
From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] thermal:thermal_hwmon: Revert recent message adjustment
Quoted 7 lines
For the sake of consistency, revert the second part of the
thermal_hwmon.chunk from commitdec07d399cc8("thermal: Don't use 'device' internal thermal zone structure field") after the first part of it has been reverted.
Quoted 16 lines
--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux-pm/drivers/thermal/thermal_hwmon.c
===================================================================drivers/thermal/thermal_hwmon.c +1
-1@@ -236,7 +236,7 @@ void thermal_remove_hwmon_sysfs(struct t temp =thermal_hwmon_lookup_temp (hwmon, tz);if (unlikely (!temp)) {/* Should never happen... */ -dev_dbg (hwmon->device,"temperature input lookup failed!\n" ); +dev_dbg (&tz->device,"temperature input lookup failed!\n" );return ; }
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 5 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>
Quoted 21 lines
---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );return ; }
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 9 lines · Daniel Lezcano
Quoted 5 lines · Zhang Rui
When the hwmon device node of a thermal zone device is not found, using
hwmon->devicecauses a kernel NULL pointer dereference.Reported-by Preble Adam C <[email protected]>Signed-off-by Zhang Rui <[email protected]>Acked-by Daniel Lezcano <[email protected]>
Applied, thanks!
Quoted 29 lines
Quoted 13 lines
---
Fixes dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
dec07d399cc8is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not.--- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/thermal_hwmon.c +0
-0drivers/thermal/thermal_hwmon.c void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) · line 235
Quoted 8 lines
drivers/thermal/thermal_hwmon.c +1
-1@@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon =thermal_hwmon_lookup_by_type (tz);if (unlikely (!hwmon)) {/* Should never happen... */ -dev_dbg (hwmon->device,"hwmon device lookup failed!\n" ); +dev_dbg (&tz->device,"hwmon device lookup failed!\n" );return ; }--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog