2020-11-02 12:29:56

by Carl Yin(殷张成)

[permalink] [raw]
Subject: [PATCH v2] 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")
Signed-off-by: carl.yin <[email protected]>
Reviewed-by: Bhaumik Bhatt <[email protected]>
---
drivers/bus/mhi/core/init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 0ffdebd..c6b43e9 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -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;

--
2.25.1


2020-11-03 22:10:04

by Hemant Kumar

[permalink] [raw]
Subject: Re: [PATCH v2] bus: mhi: core: Fix null pointer access when parsing MHI configuration



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")
> Signed-off-by: carl.yin <[email protected]>
> Reviewed-by: Bhaumik Bhatt <[email protected]>

Reviewed-by: Hemant Kumar <[email protected]>
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

2020-11-05 16:08:18

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH v2] bus: mhi: core: Fix null pointer access when parsing MHI configuration

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")
> Signed-off-by: carl.yin <[email protected]>
> Reviewed-by: Bhaumik Bhatt <[email protected]>

Reviewed-by: Manivannan Sadhasivam <[email protected]>

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

> ---
> drivers/bus/mhi/core/init.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 0ffdebd..c6b43e9 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -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;
>
> --
> 2.25.1
>

2020-11-09 12:03:50

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH v2] bus: mhi: core: Fix null pointer access when parsing MHI configuration

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")
> Signed-off-by: carl.yin <[email protected]>
> Reviewed-by: Bhaumik Bhatt <[email protected]>

Applied to mhi-next!

Thanks,
Mani

> ---
> drivers/bus/mhi/core/init.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 0ffdebd..c6b43e9 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -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;
>
> --
> 2.25.1
>