From 6f38baa1a048e9e85c237b172f90032e74581e12 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 13 Oct 2022 14:57:10 +0200 Subject: [PATCH] probe: don't store pointers to configuration data probe configuration data, passed to probe_point_add() cannot be used outside of the scope of the function, therefore storing pointers to it for later use is invalid. The pointer is only used in the notification handler to extract the buffer ID. Use the ID from the probes' persistent data instead. Signed-off-by: Guennadi Liakhovetski --- src/probe/probe.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index 7fb022735..4412ded3f 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -1189,15 +1189,17 @@ int probe_point_add(uint32_t count, struct probe_point *probe) return -EINVAL; #endif } else { + probe_point_id_t *new_buf_id = &_probe->probe_points[first_free].buffer_id; + #if CONFIG_IPC_MAJOR_4 - notifier_register(&probe[i].buffer_id.full_id, buf, NOTIFIER_ID_BUFFER_PRODUCE, + notifier_register(&new_buf_id->full_id, buf, NOTIFIER_ID_BUFFER_PRODUCE, &probe_cb_produce, 0); - notifier_register(&probe[i].buffer_id.full_id, buf, NOTIFIER_ID_BUFFER_FREE, + notifier_register(&new_buf_id->full_id, buf, NOTIFIER_ID_BUFFER_FREE, &probe_cb_free, 0); #else - notifier_register(&probe[i].buffer_id.full_id, dev->cb, NOTIFIER_ID_BUFFER_PRODUCE, + notifier_register(&new_buf_id->full_id, dev->cb, NOTIFIER_ID_BUFFER_PRODUCE, &probe_cb_produce, 0); - notifier_register(&probe[i].buffer_id.full_id, dev->cb, NOTIFIER_ID_BUFFER_FREE, + notifier_register(&new_buf_id->full_id, dev->cb, NOTIFIER_ID_BUFFER_FREE, &probe_cb_free, 0); #endif }