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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:22:50 +0000 (14:22 +0200)
commitc61e2fc87f24cae4701f352fe9ecd4c5c143106c
tree7259316bc85747b734e3f685990409afc48d4e73
parentba81399402b7d3dee1b8dfb92c008d90da0cd580
coresight: syscfg: Fix memleak on registration failure in cscfg_create_device

commit cfa5dbcdd7aece76f3415284569f2f384aff0253 upstream.

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>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-syscfg.c