coresight_get_sink_by_id() returns the sink with a reference taken by bus_find_device(), but etm_setup_aux() never drops it. The paths built for each CPU take their own references on the sink, so drop the lookup reference before returning on both the success and error paths.
Fixes: 226443925887 ("coresight: Use event attributes for sink selection") Reported-by: Sashiko sashiko-bot@kernel.org Closes: https://sashiko.dev/#/bug/linux-89fe1ee7-7e2f-4c78-a8e6-93a1a260015b Signed-off-by: James Clark james.clark@linaro.org --- drivers/hwtracing/coresight/coresight-etm-perf.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 5261061e4dd4..6946058b5401 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -519,10 +519,14 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, if (!event_data->snk_config) goto err;
+ if (user_sink) + put_device(&user_sink->dev); mutex_unlock(&coresight_mutex); return event_data;
err: + if (user_sink) + put_device(&user_sink->dev); mutex_unlock(&coresight_mutex); etm_free_aux(event_data); return NULL;