rpmsg: smd: use put_device() if device_register fail
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Thu, 8 Mar 2018 09:36:08 +0000 (15:06 +0530)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Sun, 18 Mar 2018 04:46:19 +0000 (21:46 -0700)
if device_register() returned an error! Always use put_device()
to give up the reference initialized. unregister device for
other return error.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/rpmsg/qcom_smd.c

index 92d0c6a7a837248252e112e1157d674aa6506f47..ff8101a768bc45bb199c41736efd60e383765ecf 100644 (file)
@@ -1408,6 +1408,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
        ret = device_register(&edge->dev);
        if (ret) {
                pr_err("failed to register smd edge\n");
+               put_device(&edge->dev);
                return ERR_PTR(ret);
        }
 
@@ -1428,7 +1429,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
        return edge;
 
 unregister_dev:
-       put_device(&edge->dev);
+       device_unregister(&edge->dev);
        return ERR_PTR(ret);
 }
 EXPORT_SYMBOL(qcom_smd_register_edge);