Skip to content

Commit 5839681

Browse files
Alex Elderandersson
authored andcommitted
remoteproc: qcom_q6v5_mss: fix q6v5_probe() error paths
If an error occurs in q6v5_probe() after the proxy power domains are attached, but before qcom_add_ipa_notify_subdev() is called, qcom_remove_ipa_notify_subdev() is called in the error path, which is a bug. Fix this by having that call be reached through a different label. Additionally, if qcom_add_sysmon_subdev() returns an error, the subdevs that had already been added will not be properly removed. Fix this by having the added subdevs (including the IPA notify one) be removed in this case. Finally, arrange for the sysmon subdev to be removed before the rest in the event rproc_add() returns an error. Have cleanup activity done in q6v5_remove() be done in the reverse order they are set up in q6v5_probe() (the same order they're done in the q6v5_probe() error path). Use a local variable for the remoteproc pointer, which is used repeatedly. Remove errant semicolons at the end of two function blocks. Signed-off-by: Alex Elder <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 13c060b commit 5839681

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

drivers/remoteproc/qcom_q6v5_mss.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static int q6v5_pds_enable(struct q6v5 *qproc, struct device **pds,
367367
}
368368

369369
return ret;
370-
};
370+
}
371371

372372
static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds,
373373
size_t pd_count)
@@ -1527,7 +1527,7 @@ static int q6v5_pds_attach(struct device *dev, struct device **devs,
15271527
dev_pm_domain_detach(devs[i], false);
15281528

15291529
return ret;
1530-
};
1530+
}
15311531

15321532
static void q6v5_pds_detach(struct q6v5 *qproc, struct device **pds,
15331533
size_t pd_count)
@@ -1766,17 +1766,23 @@ static int q6v5_probe(struct platform_device *pdev)
17661766
qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
17671767
if (IS_ERR(qproc->sysmon)) {
17681768
ret = PTR_ERR(qproc->sysmon);
1769-
goto detach_proxy_pds;
1769+
goto remove_subdevs;
17701770
}
17711771

17721772
ret = rproc_add(rproc);
17731773
if (ret)
1774-
goto detach_proxy_pds;
1774+
goto remove_sysmon_subdev;
17751775

17761776
return 0;
17771777

1778-
detach_proxy_pds:
1778+
remove_sysmon_subdev:
1779+
qcom_remove_sysmon_subdev(qproc->sysmon);
1780+
remove_subdevs:
17791781
qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev);
1782+
qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
1783+
qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
1784+
qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
1785+
detach_proxy_pds:
17801786
q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
17811787
detach_active_pds:
17821788
q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count);
@@ -1789,19 +1795,20 @@ static int q6v5_probe(struct platform_device *pdev)
17891795
static int q6v5_remove(struct platform_device *pdev)
17901796
{
17911797
struct q6v5 *qproc = platform_get_drvdata(pdev);
1798+
struct rproc *rproc = qproc->rproc;
17921799

1793-
rproc_del(qproc->rproc);
1800+
rproc_del(rproc);
17941801

17951802
qcom_remove_sysmon_subdev(qproc->sysmon);
1796-
qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev);
1797-
qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev);
1798-
qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev);
1799-
qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev);
1803+
qcom_remove_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev);
1804+
qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
1805+
qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
1806+
qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
18001807

1801-
q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count);
18021808
q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
1809+
q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count);
18031810

1804-
rproc_free(qproc->rproc);
1811+
rproc_free(rproc);
18051812

18061813
return 0;
18071814
}

0 commit comments

Comments
 (0)