Skip to contentSkip to conversation

bus: mhi: core: Fix null pointer access when parsing MHI configuration

PATCH Applied [email protected] 4 participants 5 messages Nov 2, 2020 – Dec 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bus: mhi: core: Fix null pointer access when parsing MHI configuration

From: "carl.yin" <[email protected]>

Functions parse_ev_cfg() and parse_ch_cfg() access mhi_cntrl->mhi_dev before it is set in function mhi_register_controller(), use cntrl_dev instead of mhi_dev.

Fixes 0cbf260820fa ("bus: mhi: core: Add support for registering MHI controllers")
---
 drivers/bus/mhi/core/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/mhi/core/init.c +2 -2
index 0ffdebd..c6b43e9 100644
@@ -610,7 +610,7 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
 {
 	struct mhi_event *mhi_event;
 	const struct mhi_event_config *event_cfg;
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	struct device *dev = mhi_cntrl->cntrl_dev;
 	int i, num;
 
 	num = config->num_events;
@@ -692,7 +692,7 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl,
 			const struct mhi_controller_config *config)
 {
 	const struct mhi_channel_config *ch_cfg;
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	struct device *dev = mhi_cntrl->cntrl_dev;
 	int i;
 	u32 chan;
 
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · On 11/2/20 4:27 AM, [email protected] wrote:

From: "carl.yin" <[email protected]>

Functions parse_ev_cfg() and parse_ch_cfg() access mhi_cntrl->mhi_dev before it is set in function mhi_register_controller(), use cntrl_dev instead of mhi_dev.

Fixes 0cbf260820fa ("bus: mhi: core: Add support for registering MHI controllers")
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v2 1/1
#2 lore raw
In reply to [email protected]
Quoted 9 lines · On Mon, Nov 02, 2020 at 08:27:10PM +0800, [email protected] wrote:

From: "carl.yin" <[email protected]>

Functions parse_ev_cfg() and parse_ch_cfg() access mhi_cntrl->mhi_dev before it is set in function mhi_register_controller(), use cntrl_dev instead of mhi_dev.

Fixes 0cbf260820fa ("bus: mhi: core: Add support for registering MHI controllers")

Nit: Your name in the Signed-off-by tag should be in a proper format like "Carl Yin". I'll fix it up while applying. But please fix it in future patches.

Thanks,
Mani

Quoted 29 lines
---
 drivers/bus/mhi/core/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/mhi/core/init.c +2 -2
index 0ffdebd..c6b43e9 100644
@@ -610,7 +610,7 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
 {
 	struct mhi_event *mhi_event;
 	const struct mhi_event_config *event_cfg;
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	struct device *dev = mhi_cntrl->cntrl_dev;
 	int i, num;
 
 	num = config->num_events;
@@ -692,7 +692,7 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl,
 			const struct mhi_controller_config *config)
 {
 	const struct mhi_channel_config *ch_cfg;
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	struct device *dev = mhi_cntrl->cntrl_dev;
 	int i;
 	u32 chan;
 
Signature · 1 line
2.25.1
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Mon, Nov 02, 2020 at 08:27:10PM +0800, [email protected] wrote:

From: "carl.yin" <[email protected]>

Functions parse_ev_cfg() and parse_ch_cfg() access mhi_cntrl->mhi_dev before it is set in function mhi_register_controller(), use cntrl_dev instead of mhi_dev.

Fixes 0cbf260820fa ("bus: mhi: core: Add support for registering MHI controllers")

Applied to mhi-next!

Thanks,
Mani

Quoted 29 lines
---
 drivers/bus/mhi/core/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/mhi/core/init.c +2 -2
index 0ffdebd..c6b43e9 100644
@@ -610,7 +610,7 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
 {
 	struct mhi_event *mhi_event;
 	const struct mhi_event_config *event_cfg;
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	struct device *dev = mhi_cntrl->cntrl_dev;
 	int i, num;
 
 	num = config->num_events;
@@ -692,7 +692,7 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl,
 			const struct mhi_controller_config *config)
 {
 	const struct mhi_channel_config *ch_cfg;
-	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	struct device *dev = mhi_cntrl->cntrl_dev;
 	int i;
 	u32 chan;
 
Signature · 1 line
2.25.1
#4 lore raw
In reply to [email protected]
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 11 lines · On Mon, 2 Nov 2020 20:27:10 +0800 you wrote:

From: "carl.yin" <[email protected]>

Functions parse_ev_cfg() and parse_ch_cfg() access mhi_cntrl->mhi_dev before it is set in function mhi_register_controller(), use cntrl_dev instead of mhi_dev.

Fixes 0cbf260820fa ("bus: mhi: core: Add support for registering MHI controllers")

[...]

Here is the summary with links:
- [v2] bus: mhi: core: Fix null pointer access when parsing MHI configuration

    https://git.kernel.org/qcom/c/f4d0b39c8425

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html