Skip to content

Commit

Permalink
rpmsg: smd: use put_device() if device_register fail
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Bjorn Andersson <[email protected]>
  • Loading branch information
ArvindYadavCs authored and andersson committed Mar 18, 2018
1 parent a901172 commit be5acd2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/rpmsg/qcom_smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down

0 comments on commit be5acd2

Please sign in to comment.