Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e55aea69 authored by David Collins's avatar David Collins
Browse files

clk: qcom: clk-aop-qmp: correct mailbox channel request logic



Ensure that the clk-aop-qmp probe function correctly returns
-EPROBE_DEFER if mbox_request_channel() returns -EPROBE_DEFER.
This avoids invalid memory dereferencing during QDSS clock
calls in the case that the AOP mailbox is not yet available.

Change-Id: I4ef07ceaace05a1911f51992a181903b4365afe2
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent 06da3fd4
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ static int qmp_update_client(struct clk_hw *hw, struct device *dev,
		struct mbox_chan *mbox)
{
	struct clk_aop_qmp *clk_aop = to_aop_qmp_clk(hw);
	int ret;

	/* Use mailbox client with blocking mode */
	clk_aop->cl.dev = dev;
@@ -239,10 +240,12 @@ static int qmp_update_client(struct clk_hw *hw, struct device *dev,

	/* Allocate mailbox channel */
	mbox = clk_aop->mbox = mbox_request_channel(&clk_aop->cl, 0);
	if (IS_ERR(clk_aop->mbox) && PTR_ERR(clk_aop->mbox) != -EPROBE_DEFER) {
		dev_err(dev, "Failed to get mailbox channel %pK %ld\n",
						mbox, PTR_ERR(mbox));
		return PTR_ERR(clk_aop->mbox);
	if (IS_ERR(clk_aop->mbox)) {
		ret = PTR_ERR(clk_aop->mbox);
		if (ret != -EPROBE_DEFER)
			dev_err(dev, "Failed to get mailbox channel, ret %d\n",
				ret);
		return ret;
	}

	return 0;