* [PATCH] coresight: Fix uninitialised pointer bug in etm_setup_aux()
@ 2020-10-28 17:43 Mike Leach
2020-10-29 16:30 ` Mathieu Poirier
0 siblings, 1 reply; 2+ messages in thread
From: Mike Leach @ 2020-10-28 17:43 UTC (permalink / raw)
To: linux-arm-kernel, coresight, mathieu.poirier, linux-kernel
Cc: suzuki.poulose, alexander.shishkin, lcherian, Mike Leach
Commit [bb1860efc817] changed the sink handling code introducing an
uninitialised pointer bug. This results in the default sink selection
failing.
Prior to commit:
static void etm_setup_aux(...)
<snip>
struct coresight_device *sink;
<snip>
/* First get the selected sink from user space. */
if (event->attr.config2) {
id = (u32)event->attr.config2;
sink = coresight_get_sink_by_id(id);
} else {
sink = coresight_get_enabled_sink(true);
}
<ctd>
*sink always initialised - possibly to NULL which triggers the
automatic sink selection.
After commit:
static void etm_setup_aux(...)
<snip>
struct coresight_device *sink;
<snip>
/* First get the selected sink from user space. */
if (event->attr.config2) {
id = (u32)event->attr.config2;
sink = coresight_get_sink_by_id(id);
}
<ctd>
*sink pointer uninitialised when not providing a sink on the perf command
line. This breaks later checks to enable automatic sink selection.
Fixes [bb1860efc817] ("coresight: etm: perf: Sink selection using sysfs is deprecated")
Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index c2c9b127d074..bdc34ca449f7 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -210,7 +210,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
u32 id;
int cpu = event->cpu;
cpumask_t *mask;
- struct coresight_device *sink;
+ struct coresight_device *sink = NULL;
struct etm_event_data *event_data = NULL;
event_data = alloc_event_data(cpu);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] coresight: Fix uninitialised pointer bug in etm_setup_aux()
2020-10-28 17:43 [PATCH] coresight: Fix uninitialised pointer bug in etm_setup_aux() Mike Leach
@ 2020-10-29 16:30 ` Mathieu Poirier
0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poirier @ 2020-10-29 16:30 UTC (permalink / raw)
To: Mike Leach
Cc: linux-arm-kernel, coresight, linux-kernel, suzuki.poulose,
alexander.shishkin, lcherian
On Wed, Oct 28, 2020 at 05:43:01PM +0000, Mike Leach wrote:
> Commit [bb1860efc817] changed the sink handling code introducing an
> uninitialised pointer bug. This results in the default sink selection
> failing.
>
> Prior to commit:
>
> static void etm_setup_aux(...)
>
> <snip>
> struct coresight_device *sink;
> <snip>
>
> /* First get the selected sink from user space. */
> if (event->attr.config2) {
> id = (u32)event->attr.config2;
> sink = coresight_get_sink_by_id(id);
> } else {
> sink = coresight_get_enabled_sink(true);
> }
> <ctd>
>
> *sink always initialised - possibly to NULL which triggers the
> automatic sink selection.
>
> After commit:
>
> static void etm_setup_aux(...)
>
> <snip>
> struct coresight_device *sink;
> <snip>
>
> /* First get the selected sink from user space. */
> if (event->attr.config2) {
> id = (u32)event->attr.config2;
> sink = coresight_get_sink_by_id(id);
> }
> <ctd>
>
> *sink pointer uninitialised when not providing a sink on the perf command
> line. This breaks later checks to enable automatic sink selection.
>
> Fixes [bb1860efc817] ("coresight: etm: perf: Sink selection using sysfs is deprecated")
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
> drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index c2c9b127d074..bdc34ca449f7 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -210,7 +210,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
> u32 id;
> int cpu = event->cpu;
> cpumask_t *mask;
> - struct coresight_device *sink;
> + struct coresight_device *sink = NULL;
Yes, obviously - thanks for catching that.
As checkpatch has complained about, the Fixes line you added isn't correct. It
should have been:
Fixes: bb1860efc817 ("coresight: etm: perf: Sink selection using sysfs is deprecated")
I made the modification and applied to my tree.
Thanks,
Mathieu
> struct etm_event_data *event_data = NULL;
>
> event_data = alloc_event_data(cpu);
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-29 16:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 17:43 [PATCH] coresight: Fix uninitialised pointer bug in etm_setup_aux() Mike Leach
2020-10-29 16:30 ` Mathieu Poirier
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).