slimbus: core: use put_device() instead of kfree()
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Fri, 9 Mar 2018 14:09:59 +0000 (14:09 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Mar 2018 16:55:52 +0000 (17:55 +0100)
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: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/slimbus/core.c

index 4988a8f4d90552a51501791ee3abe2737f428305..7ddfc675b131fba29bb9419541d58169cba5aa22 100644 (file)
@@ -141,7 +141,7 @@ static struct slim_device *slim_alloc_device(struct slim_controller *ctrl,
        sbdev->e_addr = *eaddr;
        ret = slim_add_device(ctrl, sbdev, node);
        if (ret) {
-               kfree(sbdev);
+               put_device(&sbdev->dev);
                return NULL;
        }