[PATCH RESEND] tools/lib/thermal: fix sampling handler context ptr

juhl.emildahl@gmail.com posted 1 patch 1 month, 1 week ago
tools/lib/thermal/sampling.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH RESEND] tools/lib/thermal: fix sampling handler context ptr
Posted by juhl.emildahl@gmail.com 1 month, 1 week ago
From: Emil Dahl Juhl <emdj@bang-olufsen.dk>

The sampling handler, provided by the user alongside a void* context,
was invoked with an internal structure instead of the user context.

Correct the invocation of the sampling handler to pass the user context
pointer instead.

Note that the approach taken is similar to that in events.c, and will
reduce the chances of this mistake happening if additional sampling
callbacks are added.

Fixes: 47c4b0de080a ("tools/lib/thermal: Add a thermal library")
Signed-off-by: Emil Dahl Juhl <emdj@bang-olufsen.dk>
---
 tools/lib/thermal/sampling.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/thermal/sampling.c b/tools/lib/thermal/sampling.c
index 70577423a9f0..f67c1f9ea1d7 100644
--- a/tools/lib/thermal/sampling.c
+++ b/tools/lib/thermal/sampling.c
@@ -16,6 +16,8 @@ static int handle_thermal_sample(struct nl_msg *n, void *arg)
 	struct thermal_handler_param *thp = arg;
 	struct thermal_handler *th = thp->th;

+	arg = thp->arg;
+
 	genlmsg_parse(nlh, 0, attrs, THERMAL_GENL_ATTR_MAX, NULL);

 	switch (genlhdr->cmd) {
--
2.45.0
Re: [PATCH RESEND] tools/lib/thermal: fix sampling handler context ptr
Posted by Daniel Lezcano 1 month, 1 week ago
On 15/10/2024 19:18, juhl.emildahl@gmail.com wrote:
> From: Emil Dahl Juhl <emdj@bang-olufsen.dk>
> 
> The sampling handler, provided by the user alongside a void* context,
> was invoked with an internal structure instead of the user context.
> 
> Correct the invocation of the sampling handler to pass the user context
> pointer instead.
> 
> Note that the approach taken is similar to that in events.c, and will
> reduce the chances of this mistake happening if additional sampling
> callbacks are added.
> 
> Fixes: 47c4b0de080a ("tools/lib/thermal: Add a thermal library")
> Signed-off-by: Emil Dahl Juhl <emdj@bang-olufsen.dk>
> ---

Applied, thanks


-- 
<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