[PATCH] coresight: syscfg: fix deadlock on device registration failure
yingchao deng
dengyingchao at kylinsec.com.cn
Sun Sep 6 20:06:35 PDT 2026
Gentle reminder
On 25/08/2026 09:47, yingchao wrote:
> From: Yingchao Deng <dengyingchao at kylinsec.com.cn>
>
> cscfg_create_device() calls put_device() while holding cscfg_mutex. If
> device_register() failed, put_device() drops the last reference and invokes
> cscfg_dev_release(), which takes cscfg_mutex again, deadlocking.
>
> Unlock cscfg_mutex before calling put_device().
>
> Fixes: cfa5dbcdd7ae ("coresight: syscfg: Fix memleak on registration failure in cscfg_create_device")
> Signed-off-by: Yingchao Deng <dengyingchao at kylinsec.com.cn>
> ---
> drivers/hwtracing/coresight/coresight-syscfg.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
> index 2bfdd7b45e49..d0e7e4720e46 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.c
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.c
> @@ -1210,8 +1210,14 @@ static int cscfg_create_device(void)
> dev->init_name = "cs_system_cfg";
>
> err = device_register(dev);
> - if (err)
> + if (err) {
> + /* put_device() triggers cscfg_dev_release() which takes
> + * cscfg_mutex, so drop the lock first to avoid deadlocking.
> + */
> + mutex_unlock(&cscfg_mutex);
> put_device(dev);
> + return err;
> + }
>
> create_dev_exit_unlock:
> mutex_unlock(&cscfg_mutex);
More information about the linux-arm-kernel
mailing list