Skip to content

Commit

Permalink
coresight: syscfg: Fix memleak on registration failure in cscfg_creat…
Browse files Browse the repository at this point in the history
…e_device

commit cfa5dbc 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: 85e2414 ("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>
  • Loading branch information
Miaoqian Lin authored and Greg Kroah-Hartman committed Apr 8, 2022
1 parent 4d34bf2 commit 412225b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hwtracing/coresight/coresight-syscfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 412225b

Please sign in to comment.