remoteproc: fix null pointer dereference on glink only platforms
authorSibi Sankar <sibis@codeaurora.org>
Tue, 3 Apr 2018 18:15:15 +0000 (23:45 +0530)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Fri, 6 Apr 2018 05:53:16 +0000 (22:53 -0700)
Currently calling list_del on smd subdev remove path results in
null pointer dereference on glink only platforms. Fix this by
adding safety checks in glink/smd subdev remove paths.

Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/remoteproc/qcom_common.c

index 9e47a147c1318f95f65db2dc5a61e7c85ac21856..acfc99f82fb808fbc3f83462c781eadb7a65bed0 100644 (file)
@@ -75,6 +75,9 @@ EXPORT_SYMBOL_GPL(qcom_add_glink_subdev);
  */
 void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink)
 {
+       if (!glink->node)
+               return;
+
        rproc_remove_subdev(rproc, &glink->subdev);
        of_node_put(glink->node);
 }
@@ -165,6 +168,9 @@ EXPORT_SYMBOL_GPL(qcom_add_smd_subdev);
  */
 void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
 {
+       if (!smd->node)
+               return;
+
        rproc_remove_subdev(rproc, &smd->subdev);
        of_node_put(smd->node);
 }