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

Commit 6e8d77cd authored by Hemant Kumar's avatar Hemant Kumar
Browse files

mhi: core: Add NULL check in mhi_get_exec_env



In case power up failed due to incorrect bhi offset
bhi pointer in mhi controller remains NULL. Later if
MHI controller forces RDDM it checks the execution
environment by accessing the BHI offset. This results
into NULL pointer dereference. Fix this by adding NULL
check for both mhi controller and bhi pointer before
reading the BHI offset.

Change-Id: I93f8918d7d595a77a5c8bcb6fd610f1a2b484fc4
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent cef19e9e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -244,8 +244,13 @@ static enum mhi_ee mhi_translate_dev_ee(struct mhi_controller *mhi_cntrl,

enum mhi_ee mhi_get_exec_env(struct mhi_controller *mhi_cntrl)
{
	int ret;
	u32 exec;
	int ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_EXECENV, &exec);

	if (!mhi_cntrl || !mhi_cntrl->bhi)
		return MHI_EE_MAX;

	ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_EXECENV, &exec);

	return (ret) ? MHI_EE_MAX : mhi_translate_dev_ee(mhi_cntrl, exec);
}