[PATCH 13/25] coresight: trbe: Handle an already disabled sink

James Clark james.clark at linaro.org
Mon Oct 19 05:44:27 PDT 2026



On 15/09/2026 16:48, Leo Yan wrote:
> arm_trbe_disable() detaches the trace buffer and clears cpudata->buf. A
> subsequent disable dereferences this NULL pointer in the buffer consistency
> check before testing whether the sink is still in perf mode.
> 
> Check the mode before accessing the buffer and return success when the
> sink is already disabled. This allows deferred event cleanup to revisit a
> path that an AUX snapshot has already disabled after a failure.
> 
> Assisted-by: Codex:gpt-6
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>   drivers/hwtracing/coresight/coresight-trbe.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index 8eb625d3fc99db57a18e35ef59ef814dacf20a09..6da89a890712d32e87a15f7c564ff4dc4d197bb1 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -1098,11 +1098,15 @@ static int arm_trbe_disable(struct coresight_device *csdev)
>   	struct trbe_cpudata *cpudata = dev_get_drvdata(&csdev->dev);
>   	struct trbe_buf *buf = cpudata->buf;
>   
> +	/* A failed AUX snapshot may have already disabled the sink. */
> +	if (cpudata->mode == CS_MODE_DISABLED)
> +		return 0;
> +	if (cpudata->mode != CS_MODE_PERF)
> +		return -EINVAL;
> +
>   	WARN_ON(buf->cpudata != cpudata);
>   	WARN_ON(cpudata->cpu != smp_processor_id());
>   	WARN_ON(cpudata->drvdata != drvdata);
> -	if (cpudata->mode != CS_MODE_PERF)
> -		return -EINVAL;
>   
>   	trbe_drain_and_disable_local(cpudata);
>   	buf->cpudata = NULL;
> 

Reviewed-by: James Clark <james.clark at linaro.org>




More information about the linux-arm-kernel mailing list