[PATCH] coresight: tpdm: initialize spinlock before exposing sysfs

Jie Gan jie.gan at oss.qualcomm.com
Mon Aug 24 20:09:54 PDT 2026



On 8/25/2026 10:06 AM, yingchao wrote:
> From: Yingchao Deng <dengyingchao at kylinsec.com.cn>
> 
> tpdm_probe() initializes drvdata->spinlock after coresight_register(), but
> the sysfs attributes registered by coresight_register() use the spinlock.
> This exposes a window where a concurrent sysfs write can lock an
> uninitialized spinlock.
> 

There is only a very small window during which users have a chance to 
access the sysfs nodes. But still worthy to fix it.

Reviewed-by: Jie Gan <jie.gan at oss.qualcomm.com>

> Initialize the spinlock before coresight_register().
> 
> Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
> Signed-off-by: Yingchao Deng <dengyingchao at kylinsec.com.cn>
> ---
>   drivers/hwtracing/coresight/coresight-tpdm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
> index 8464edbba2d4..50d1351772b9 100644
> --- a/drivers/hwtracing/coresight/coresight-tpdm.c
> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c
> @@ -1457,12 +1457,12 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>   		desc.groups = tpdm_attr_grps;
>   	else
>   		desc.groups = static_tpdm_attr_grps;
> +	spin_lock_init(&drvdata->spinlock);
> +
>   	drvdata->csdev = coresight_register(&desc);
>   	if (IS_ERR(drvdata->csdev))
>   		return PTR_ERR(drvdata->csdev);
>   
> -	spin_lock_init(&drvdata->spinlock);
> -
>   	return 0;
>   }
>   




More information about the linux-arm-kernel mailing list