rpmsg: smd: use put_device() if device_register fail

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>
This commit is contained in:
Arvind Yadav 2018-03-08 15:06:08 +05:30 committed by Bjorn Andersson
parent a9011726c4
commit be5acd246d
1 changed files with 2 additions and 1 deletions

View 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);