rpmsg: glink: use put_device() if device_register fail
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Thu, 8 Mar 2018 09:36:07 +0000 (15:06 +0530)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Sun, 18 Mar 2018 04:45:57 +0000 (21:45 -0700)
if device_register() returned an error! Always use put_device()
to give up the reference initialized. And 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_glink_smem.c

index 892f2b92a4d854d5122887f21591184e18973b0f..3fa9d43e2c879c82a12c7866737fa5b3d92909c6 100644 (file)
@@ -217,6 +217,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
        ret = device_register(dev);
        if (ret) {
                pr_err("failed to register glink edge\n");
+               put_device(dev);
                return ERR_PTR(ret);
        }
 
@@ -299,7 +300,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
        return glink;
 
 err_put_dev:
-       put_device(dev);
+       device_unregister(dev);
 
        return ERR_PTR(ret);
 }