]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/lib/thermal: Fix sampling handler context ptr
authorEmil Dahl Juhl <emdj@bang-olufsen.dk>
Tue, 15 Oct 2024 17:18:26 +0000 (19:18 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 4 Nov 2024 14:38:29 +0000 (15:38 +0100)
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>
Link: https://lore.kernel.org/r/20241015171826.170154-1-emdj@bang-olufsen.dk
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
tools/lib/thermal/sampling.c

index 70577423a9f0c29f6719c3570cf631aab26a07d7..f67c1f9ea1d78553ef3c699c50fc3feef195e991 100644 (file)
@@ -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) {