]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
coresight: use put_device() instead of kfree()
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Wed, 9 May 2018 18:06:03 +0000 (12:06 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 May 2018 14:19:59 +0000 (16:19 +0200)
Never directly free @dev after calling device_register(), even
if it returned an error. Always use put_device() to give up the
reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight.c

index 389c4baeca9d261310357242ad7cd68c97fbdf3b..132dfbcd90c15719d25cd3a57138859f8cf2a7f8 100644 (file)
@@ -1026,8 +1026,10 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
        dev_set_name(&csdev->dev, "%s", desc->pdata->name);
 
        ret = device_register(&csdev->dev);
-       if (ret)
-               goto err_device_register;
+       if (ret) {
+               put_device(&csdev->dev);
+               goto err_kzalloc_csdev;
+       }
 
        mutex_lock(&coresight_mutex);
 
@@ -1038,8 +1040,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
 
        return csdev;
 
-err_device_register:
-       kfree(conns);
 err_kzalloc_conns:
        kfree(refcnts);
 err_kzalloc_refcnts: