* [PATCH] thermal: Fix UUID string comparison in current_uuid_store()
@ 2025-10-17 7:27 Kaushlendra Kumar
2025-10-29 16:40 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Kaushlendra Kumar @ 2025-10-17 7:27 UTC (permalink / raw)
To: rafael, daniel.lezcano, rui.zhang, srinivas.pandruvada
Cc: linux-pm, Kaushlendra Kumar
Use strlen() for UUID matching instead of sizeof() to ensure
correct comparison of supported UUIDs. sizeof() returns pointer
size instead of actual string length, causing incomplete UUID
matching.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index 908cc1bf57f1..236003d12dc7 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -199,7 +199,7 @@ static ssize_t current_uuid_store(struct device *dev,
for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; ++i) {
if (!strncmp(buf, int3400_thermal_uuids[i],
- sizeof(int3400_thermal_uuids[i]) - 1)) {
+ strlen(int3400_thermal_uuids[i]))) {
/*
* If we have a list of supported UUIDs, make sure
* this one is supported.
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] thermal: Fix UUID string comparison in current_uuid_store()
2025-10-17 7:27 [PATCH] thermal: Fix UUID string comparison in current_uuid_store() Kaushlendra Kumar
@ 2025-10-29 16:40 ` Rafael J. Wysocki
2025-10-29 18:40 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2025-10-29 16:40 UTC (permalink / raw)
To: Kaushlendra Kumar
Cc: rafael, daniel.lezcano, rui.zhang, srinivas.pandruvada, linux-pm
On Fri, Oct 17, 2025 at 9:29 AM Kaushlendra Kumar
<kaushlendra.kumar@intel.com> wrote:
>
> Use strlen() for UUID matching instead of sizeof() to ensure
> correct comparison of supported UUIDs. sizeof() returns pointer
> size instead of actual string length, causing incomplete UUID
> matching.
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> ---
> drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> index 908cc1bf57f1..236003d12dc7 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> @@ -199,7 +199,7 @@ static ssize_t current_uuid_store(struct device *dev,
>
> for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; ++i) {
Exercise for the reader: Add a printk() here to print
sizeof(int3400_thermal_uuids[i]) and see what number gets printed.
> if (!strncmp(buf, int3400_thermal_uuids[i],
> - sizeof(int3400_thermal_uuids[i]) - 1)) {
> + strlen(int3400_thermal_uuids[i]))) {
> /*
> * If we have a list of supported UUIDs, make sure
> * this one is supported.
> --
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] thermal: Fix UUID string comparison in current_uuid_store()
2025-10-29 16:40 ` Rafael J. Wysocki
@ 2025-10-29 18:40 ` Rafael J. Wysocki
2025-10-30 4:04 ` Kumar, Kaushlendra
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2025-10-29 18:40 UTC (permalink / raw)
To: Kaushlendra Kumar
Cc: daniel.lezcano, rui.zhang, srinivas.pandruvada, linux-pm
On Wed, Oct 29, 2025 at 5:40 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Fri, Oct 17, 2025 at 9:29 AM Kaushlendra Kumar
> <kaushlendra.kumar@intel.com> wrote:
> >
> > Use strlen() for UUID matching instead of sizeof() to ensure
> > correct comparison of supported UUIDs. sizeof() returns pointer
> > size instead of actual string length, causing incomplete UUID
> > matching.
> >
> > Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> > ---
> > drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> > index 908cc1bf57f1..236003d12dc7 100644
> > --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> > +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> > @@ -199,7 +199,7 @@ static ssize_t current_uuid_store(struct device *dev,
> >
> > for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; ++i) {
>
> Exercise for the reader: Add a printk() here to print
> sizeof(int3400_thermal_uuids[i]) and see what number gets printed.
It is 8, but note that comparing the first 7 characters is practically
sufficient to distinguish all of the UUIDs in int3400_thermal_uuids[]
from each other.
Also, this change would alter the kernel ABI, possibly confusing users
who might notice that the first 7 characters mattered and might start
to rely on that.
If you want to clean up that piece of code, please change it to pass a
symbol representing the number 7 as the last argument to strncmp(),
but that is as much as can be done here.
> > if (!strncmp(buf, int3400_thermal_uuids[i],
> > - sizeof(int3400_thermal_uuids[i]) - 1)) {
> > + strlen(int3400_thermal_uuids[i]))) {
> > /*
> > * If we have a list of supported UUIDs, make sure
> > * this one is supported.
> > --
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] thermal: Fix UUID string comparison in current_uuid_store()
2025-10-29 18:40 ` Rafael J. Wysocki
@ 2025-10-30 4:04 ` Kumar, Kaushlendra
0 siblings, 0 replies; 4+ messages in thread
From: Kumar, Kaushlendra @ 2025-10-30 4:04 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: daniel.lezcano@linaro.org, Zhang, Rui,
srinivas.pandruvada@linux.intel.com, linux-pm@vger.kernel.org
On Wed, Oct 29, 2025 at 5:40 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> Also, this change would alter the kernel ABI, possibly confusing users who might notice that the first 7 characters mattered and might start to rely on that.
>
> If you want to clean up that piece of code, please change it to pass a symbol representing the number 7 as the last argument to strncmp(), but that is as much as can be done here.
You're right about the ABI concern. I have sent a v2 patch that uses a
symbolic constant for the 7-character comparison to maintain existing behavior
Thanks for the Review!
Kaushlendra
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-30 4:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 7:27 [PATCH] thermal: Fix UUID string comparison in current_uuid_store() Kaushlendra Kumar
2025-10-29 16:40 ` Rafael J. Wysocki
2025-10-29 18:40 ` Rafael J. Wysocki
2025-10-30 4:04 ` Kumar, Kaushlendra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).