diff mbox series

[v3] usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle

Message ID 20210921113754.767631-1-festevam@gmail.com (mailing list archive)
State Accepted
Commit 8253a34bfae3278baca52fc1209b7c29270486ca
Headers show
Series [v3] usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle | expand

Commit Message

Fabio Estevam Sept. 21, 2021, 11:37 a.m. UTC
When passing 'phys' in the devicetree to describe the USB PHY phandle
(which is the recommended way according to
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
following NULL pointer dereference is observed on i.MX7 and i.MX8MM:

[    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
[    1.498170] Mem abort info:
[    1.500966]   ESR = 0x96000044
[    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
[    1.509356]   SET = 0, FnV = 0
[    1.512416]   EA = 0, S1PTW = 0
[    1.515569]   FSC = 0x04: level 0 translation fault
[    1.520458] Data abort info:
[    1.523349]   ISV = 0, ISS = 0x00000044
[    1.527196]   CM = 0, WnR = 1
[    1.530176] [0000000000000098] user address but active_mm is swapper
[    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
[    1.542125] Modules linked in:
[    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
[    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
[    1.557133] Workqueue: events_unbound deferred_probe_work_func
[    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
[    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
[    1.573973] lr : imx7d_charger_detection+0x22c/0x510

This happens because the charger functions check for the phy presence
inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
(ci->usb_phy) instead.

This causes the NULL pointer dereference inside imx7d_charger_detection().

Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.

Tested on a imx7s-warp board.

Cc: stable@vger.kernel.org
Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Changes since v2:

- Added Frieder's reviewed-by tag.
- Cc stable
- Improved the commit log and fixed typo in 'dereferenced'

 drivers/usb/chipidea/ci_hdrc_imx.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Frieder Schrempf Sept. 30, 2021, 2:36 p.m. UTC | #1
On 21.09.21 13:37, Fabio Estevam wrote:
> When passing 'phys' in the devicetree to describe the USB PHY phandle
> (which is the recommended way according to
> Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> 
> [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> [    1.498170] Mem abort info:
> [    1.500966]   ESR = 0x96000044
> [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> [    1.509356]   SET = 0, FnV = 0
> [    1.512416]   EA = 0, S1PTW = 0
> [    1.515569]   FSC = 0x04: level 0 translation fault
> [    1.520458] Data abort info:
> [    1.523349]   ISV = 0, ISS = 0x00000044
> [    1.527196]   CM = 0, WnR = 1
> [    1.530176] [0000000000000098] user address but active_mm is swapper
> [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> [    1.542125] Modules linked in:
> [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> 
> This happens because the charger functions check for the phy presence
> inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> (ci->usb_phy) instead.
> 
> This causes the NULL pointer dereference inside imx7d_charger_detection().
> 
> Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> 
> Tested on a imx7s-warp board.
> 
> Cc: stable@vger.kernel.org
> Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>

Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>

> ---
> Changes since v2:
> 
> - Added Frieder's reviewed-by tag.
> - Cc stable
> - Improved the commit log and fixed typo in 'dereferenced'
> 
>  drivers/usb/chipidea/ci_hdrc_imx.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 8b7bc10b6e8b..f1d100671ee6 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -420,11 +420,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  	data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
>  	if (IS_ERR(data->phy)) {
>  		ret = PTR_ERR(data->phy);
> -		/* Return -EINVAL if no usbphy is available */
> -		if (ret == -ENODEV)
> -			data->phy = NULL;
> -		else
> -			goto err_clk;
> +		if (ret == -ENODEV) {
> +			data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
> +			if (IS_ERR(data->phy)) {
> +				ret = PTR_ERR(data->phy);
> +				if (ret == -ENODEV)
> +					data->phy = NULL;
> +				else
> +					goto err_clk;
> +			}
> +		}
>  	}
>  
>  	pdata.usb_phy = data->phy;
>
Peter Chen Oct. 1, 2021, 7:21 a.m. UTC | #2
On 21-09-30 16:36:51, Frieder Schrempf wrote:
> On 21.09.21 13:37, Fabio Estevam wrote:
> > When passing 'phys' in the devicetree to describe the USB PHY phandle
> > (which is the recommended way according to
> > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> > following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> > 
> > [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> > [    1.498170] Mem abort info:
> > [    1.500966]   ESR = 0x96000044
> > [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> > [    1.509356]   SET = 0, FnV = 0
> > [    1.512416]   EA = 0, S1PTW = 0
> > [    1.515569]   FSC = 0x04: level 0 translation fault
> > [    1.520458] Data abort info:
> > [    1.523349]   ISV = 0, ISS = 0x00000044
> > [    1.527196]   CM = 0, WnR = 1
> > [    1.530176] [0000000000000098] user address but active_mm is swapper
> > [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> > [    1.542125] Modules linked in:
> > [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> > [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> > [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> > [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> > [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> > [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> > 
> > This happens because the charger functions check for the phy presence
> > inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> > core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> > (ci->usb_phy) instead.
> > 
> > This causes the NULL pointer dereference inside imx7d_charger_detection().
> > 
> > Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> > 
> > Tested on a imx7s-warp board.
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> > Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>

Applied, thanks.

Peter
> 
> > ---
> > Changes since v2:
> > 
> > - Added Frieder's reviewed-by tag.
> > - Cc stable
> > - Improved the commit log and fixed typo in 'dereferenced'
> > 
> >  drivers/usb/chipidea/ci_hdrc_imx.c | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> > index 8b7bc10b6e8b..f1d100671ee6 100644
> > --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> > +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> > @@ -420,11 +420,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> >  	data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> >  	if (IS_ERR(data->phy)) {
> >  		ret = PTR_ERR(data->phy);
> > -		/* Return -EINVAL if no usbphy is available */
> > -		if (ret == -ENODEV)
> > -			data->phy = NULL;
> > -		else
> > -			goto err_clk;
> > +		if (ret == -ENODEV) {
> > +			data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
> > +			if (IS_ERR(data->phy)) {
> > +				ret = PTR_ERR(data->phy);
> > +				if (ret == -ENODEV)
> > +					data->phy = NULL;
> > +				else
> > +					goto err_clk;
> > +			}
> > +		}
> >  	}
> >  
> >  	pdata.usb_phy = data->phy;
> >
Peter Chen Oct. 4, 2021, 6:51 a.m. UTC | #3
On 21-09-30 16:36:51, Frieder Schrempf wrote:
> On 21.09.21 13:37, Fabio Estevam wrote:
> > When passing 'phys' in the devicetree to describe the USB PHY phandle
> > (which is the recommended way according to
> > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> > following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> > 
> > [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> > [    1.498170] Mem abort info:
> > [    1.500966]   ESR = 0x96000044
> > [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> > [    1.509356]   SET = 0, FnV = 0
> > [    1.512416]   EA = 0, S1PTW = 0
> > [    1.515569]   FSC = 0x04: level 0 translation fault
> > [    1.520458] Data abort info:
> > [    1.523349]   ISV = 0, ISS = 0x00000044
> > [    1.527196]   CM = 0, WnR = 1
> > [    1.530176] [0000000000000098] user address but active_mm is swapper
> > [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> > [    1.542125] Modules linked in:
> > [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> > [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> > [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> > [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> > [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> > [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> > 
> > This happens because the charger functions check for the phy presence
> > inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> > core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> > (ci->usb_phy) instead.
> > 
> > This causes the NULL pointer dereference inside imx7d_charger_detection().
> > 
> > Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> > 
> > Tested on a imx7s-warp board.
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> > Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>

Acked-by: Peter Chen <peter.chen@kernel.org>

Greg, would you please help apply it?
Greg KH Oct. 4, 2021, 7:11 a.m. UTC | #4
On Mon, Oct 04, 2021 at 02:51:42PM +0800, Peter Chen wrote:
> On 21-09-30 16:36:51, Frieder Schrempf wrote:
> > On 21.09.21 13:37, Fabio Estevam wrote:
> > > When passing 'phys' in the devicetree to describe the USB PHY phandle
> > > (which is the recommended way according to
> > > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> > > following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> > > 
> > > [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> > > [    1.498170] Mem abort info:
> > > [    1.500966]   ESR = 0x96000044
> > > [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> > > [    1.509356]   SET = 0, FnV = 0
> > > [    1.512416]   EA = 0, S1PTW = 0
> > > [    1.515569]   FSC = 0x04: level 0 translation fault
> > > [    1.520458] Data abort info:
> > > [    1.523349]   ISV = 0, ISS = 0x00000044
> > > [    1.527196]   CM = 0, WnR = 1
> > > [    1.530176] [0000000000000098] user address but active_mm is swapper
> > > [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> > > [    1.542125] Modules linked in:
> > > [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> > > [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> > > [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> > > [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> > > [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> > > [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> > > 
> > > This happens because the charger functions check for the phy presence
> > > inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> > > core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> > > (ci->usb_phy) instead.
> > > 
> > > This causes the NULL pointer dereference inside imx7d_charger_detection().
> > > 
> > > Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> > > 
> > > Tested on a imx7s-warp board.
> > > 
> > > Cc: stable@vger.kernel.org
> > > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> > > Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> > > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > > Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > 
> > Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> Acked-by: Peter Chen <peter.chen@kernel.org>
> 
> Greg, would you please help apply it?

Sure.  But I have usually been ignoring chipidea patches and hoping you
would pick them up and forward them on to me.  Should I no longer do
that and just wait for an ack from you?  That's fine with me, I've been
doing it with gadget patches for a while now.

thanks,

greg k-h
Peter Chen Oct. 4, 2021, 7:20 a.m. UTC | #5
On 21-10-04 09:11:36, Greg KH wrote:
> On Mon, Oct 04, 2021 at 02:51:42PM +0800, Peter Chen wrote:
> > On 21-09-30 16:36:51, Frieder Schrempf wrote:
> > > On 21.09.21 13:37, Fabio Estevam wrote:
> > > > When passing 'phys' in the devicetree to describe the USB PHY phandle
> > > > (which is the recommended way according to
> > > > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> > > > following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> > > > 
> > > > [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> > > > [    1.498170] Mem abort info:
> > > > [    1.500966]   ESR = 0x96000044
> > > > [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> > > > [    1.509356]   SET = 0, FnV = 0
> > > > [    1.512416]   EA = 0, S1PTW = 0
> > > > [    1.515569]   FSC = 0x04: level 0 translation fault
> > > > [    1.520458] Data abort info:
> > > > [    1.523349]   ISV = 0, ISS = 0x00000044
> > > > [    1.527196]   CM = 0, WnR = 1
> > > > [    1.530176] [0000000000000098] user address but active_mm is swapper
> > > > [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> > > > [    1.542125] Modules linked in:
> > > > [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> > > > [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> > > > [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> > > > [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> > > > [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> > > > [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> > > > 
> > > > This happens because the charger functions check for the phy presence
> > > > inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> > > > core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> > > > (ci->usb_phy) instead.
> > > > 
> > > > This causes the NULL pointer dereference inside imx7d_charger_detection().
> > > > 
> > > > Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> > > > 
> > > > Tested on a imx7s-warp board.
> > > > 
> > > > Cc: stable@vger.kernel.org
> > > > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> > > > Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> > > > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > > > Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > > 
> > > Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > 
> > Acked-by: Peter Chen <peter.chen@kernel.org>
> > 
> > Greg, would you please help apply it?
> 
> Sure.  But I have usually been ignoring chipidea patches and hoping you
> would pick them up and forward them on to me.  Should I no longer do
> that and just wait for an ack from you?

Yes, please do that way, thanks.
Greg KH Oct. 5, 2021, 10:38 a.m. UTC | #6
On Mon, Oct 04, 2021 at 03:20:39PM +0800, Peter Chen wrote:
> On 21-10-04 09:11:36, Greg KH wrote:
> > On Mon, Oct 04, 2021 at 02:51:42PM +0800, Peter Chen wrote:
> > > On 21-09-30 16:36:51, Frieder Schrempf wrote:
> > > > On 21.09.21 13:37, Fabio Estevam wrote:
> > > > > When passing 'phys' in the devicetree to describe the USB PHY phandle
> > > > > (which is the recommended way according to
> > > > > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> > > > > following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> > > > > 
> > > > > [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> > > > > [    1.498170] Mem abort info:
> > > > > [    1.500966]   ESR = 0x96000044
> > > > > [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> > > > > [    1.509356]   SET = 0, FnV = 0
> > > > > [    1.512416]   EA = 0, S1PTW = 0
> > > > > [    1.515569]   FSC = 0x04: level 0 translation fault
> > > > > [    1.520458] Data abort info:
> > > > > [    1.523349]   ISV = 0, ISS = 0x00000044
> > > > > [    1.527196]   CM = 0, WnR = 1
> > > > > [    1.530176] [0000000000000098] user address but active_mm is swapper
> > > > > [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> > > > > [    1.542125] Modules linked in:
> > > > > [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> > > > > [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> > > > > [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> > > > > [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> > > > > [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> > > > > [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> > > > > 
> > > > > This happens because the charger functions check for the phy presence
> > > > > inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> > > > > core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> > > > > (ci->usb_phy) instead.
> > > > > 
> > > > > This causes the NULL pointer dereference inside imx7d_charger_detection().
> > > > > 
> > > > > Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> > > > > 
> > > > > Tested on a imx7s-warp board.
> > > > > 
> > > > > Cc: stable@vger.kernel.org
> > > > > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> > > > > Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> > > > > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > > > > Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > > > 
> > > > Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > > 
> > > Acked-by: Peter Chen <peter.chen@kernel.org>
> > > 
> > > Greg, would you please help apply it?
> > 
> > Sure.  But I have usually been ignoring chipidea patches and hoping you
> > would pick them up and forward them on to me.  Should I no longer do
> > that and just wait for an ack from you?
> 
> Yes, please do that way, thanks.

Ok, I see at least 1 patch series and one patch that needs your review:
	https://lore.kernel.org/r/1629825378-8089-1-git-send-email-manish.narani@xilinx.com
	https://lore.kernel.org/r/20210913140005.955699-1-piyush.mehta@xilinx.com

Can you look at them please?

thanks,

greg k-h
Peter Chen Oct. 7, 2021, 5:16 a.m. UTC | #7
On 21-10-05 12:38:29, Greg KH wrote:
> On Mon, Oct 04, 2021 at 03:20:39PM +0800, Peter Chen wrote:
> > On 21-10-04 09:11:36, Greg KH wrote:
> > > On Mon, Oct 04, 2021 at 02:51:42PM +0800, Peter Chen wrote:
> > > > On 21-09-30 16:36:51, Frieder Schrempf wrote:
> > > > > On 21.09.21 13:37, Fabio Estevam wrote:
> > > > > > When passing 'phys' in the devicetree to describe the USB PHY phandle
> > > > > > (which is the recommended way according to
> > > > > > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
> > > > > > following NULL pointer dereference is observed on i.MX7 and i.MX8MM:
> > > > > > 
> > > > > > [    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> > > > > > [    1.498170] Mem abort info:
> > > > > > [    1.500966]   ESR = 0x96000044
> > > > > > [    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
> > > > > > [    1.509356]   SET = 0, FnV = 0
> > > > > > [    1.512416]   EA = 0, S1PTW = 0
> > > > > > [    1.515569]   FSC = 0x04: level 0 translation fault
> > > > > > [    1.520458] Data abort info:
> > > > > > [    1.523349]   ISV = 0, ISS = 0x00000044
> > > > > > [    1.527196]   CM = 0, WnR = 1
> > > > > > [    1.530176] [0000000000000098] user address but active_mm is swapper
> > > > > > [    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> > > > > > [    1.542125] Modules linked in:
> > > > > > [    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> > > > > > [    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> > > > > > [    1.557133] Workqueue: events_unbound deferred_probe_work_func
> > > > > > [    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> > > > > > [    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> > > > > > [    1.573973] lr : imx7d_charger_detection+0x22c/0x510
> > > > > > 
> > > > > > This happens because the charger functions check for the phy presence
> > > > > > inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
> > > > > > core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
> > > > > > (ci->usb_phy) instead.
> > > > > > 
> > > > > > This causes the NULL pointer dereference inside imx7d_charger_detection().
> > > > > > 
> > > > > > Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
> > > > > > 
> > > > > > Tested on a imx7s-warp board.
> > > > > > 
> > > > > > Cc: stable@vger.kernel.org
> > > > > > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> > > > > > Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> > > > > > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > > > > > Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > > > > 
> > > > > Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> > > > 
> > > > Acked-by: Peter Chen <peter.chen@kernel.org>
> > > > 
> > > > Greg, would you please help apply it?
> > > 
> > > Sure.  But I have usually been ignoring chipidea patches and hoping you
> > > would pick them up and forward them on to me.  Should I no longer do
> > > that and just wait for an ack from you?
> > 
> > Yes, please do that way, thanks.
> 
> Ok, I see at least 1 patch series and one patch that needs your review:
> 	https://lore.kernel.org/r/1629825378-8089-1-git-send-email-manish.narani@xilinx.com
> 	https://lore.kernel.org/r/20210913140005.955699-1-piyush.mehta@xilinx.com
> 
> Can you look at them please?
> 

Reviewed, thanks for reminding.
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 8b7bc10b6e8b..f1d100671ee6 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -420,11 +420,16 @@  static int ci_hdrc_imx_probe(struct platform_device *pdev)
 	data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
 	if (IS_ERR(data->phy)) {
 		ret = PTR_ERR(data->phy);
-		/* Return -EINVAL if no usbphy is available */
-		if (ret == -ENODEV)
-			data->phy = NULL;
-		else
-			goto err_clk;
+		if (ret == -ENODEV) {
+			data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
+			if (IS_ERR(data->phy)) {
+				ret = PTR_ERR(data->phy);
+				if (ret == -ENODEV)
+					data->phy = NULL;
+				else
+					goto err_clk;
+			}
+		}
 	}
 
 	pdata.usb_phy = data->phy;