Commit cfa5dbcd authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Suzuki K Poulose

coresight: syscfg: Fix memleak on registration failure in cscfg_create_device

device_register() calls device_initialize(),
according to doc of device_initialize:

    Use put_device() to give up your reference instead of freeing
    * @dev directly once you have called this function.

To prevent potential memleak, use put_device() for error handling.
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Fixes: 85e2414c ("coresight: syscfg: Initial coresight system configuration")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220124124121.8888-1-linmq006@gmail.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
parent ea75a342
......@@ -1049,7 +1049,7 @@ static int cscfg_create_device(void)
err = device_register(dev);
if (err)
cscfg_dev_release(dev);
put_device(dev);
create_dev_exit_unlock:
mutex_unlock(&cscfg_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment