coresight: syscfg: Fix memleak on registration failure in cscfg_create_device
authorMiaoqian Lin <linmq006@gmail.com>
Mon, 24 Jan 2022 12:41:21 +0000 (12:41 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Tue, 22 Feb 2022 15:57:00 +0000 (15:57 +0000)
commit5340bf5df9d26018cd162204008a4a326cbfd35a
tree00a24f2ffcb313413cfc5e915b907d5881936898
parent91a2f2941df2c9e512aabb3be28ad97adafb7c0f
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: Miaoqian Lin <linmq006@gmail.com>
Fixes: 85e2414c518a ("coresight: syscfg: Initial coresight system configuration")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220124124121.8888-1-linmq006@gmail.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/hwtracing/coresight/coresight-syscfg.c