linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified
@ 2014-02-27 15:42 Alexandre Belloni
  2014-02-28 14:35 ` Nicolas Ferre
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2014-02-27 15:42 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: linux-kernel, linux-arm-kernel, linux-usb, Nicolas Ferre,
	Greg Kroah-Hartman, Maxime Ripard, Gregory Clement,
	Alexandre Belloni

If no endpoints are present in the device tree, the kernel will cras hwith the
following error:

Unable to handle kernel paging request at virtual address 00101008
[...]
[<c0222ff4>] (composite_dev_prepare) from [<c022326c>] (composite_bind+0x5c/0x190)
[<c022326c>] (composite_bind) from [<c021ff8c>] (udc_bind_to_driver+0x48/0xf0)
[<c021ff8c>] (udc_bind_to_driver) from [<c02208e0>] (usb_gadget_probe_driver+0x7c/0xa0)
[<c02208e0>] (usb_gadget_probe_driver) from [<c0008970>] (do_one_initcall+0x94/0x140)
[<c0008970>] (do_one_initcall) from [<c04b4b50>] (kernel_init_freeable+0xec/0x1b4)
[<c04b4b50>] (kernel_init_freeable) from [<c0376cc4>] (kernel_init+0x8/0xe4)
[<c0376cc4>] (kernel_init) from [<c0009590>] (ret_from_fork+0x14/0x24)
Code: e5950014 e1a04001 e5902008 e3a010d0 (e5922008)
---[ end trace 35c74bdd89b373d0 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

This checks for that case and returns an error, not allowing the driver to be
loaded with no endpoints.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/usb/gadget/atmel_usba_udc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 52771d4c44bc..e3e0c8ff242e 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1914,6 +1914,12 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
 		i++;
 	}
 
+	if (i == 0) {
+		dev_err(&pdev->dev, "of_probe: no endpoint specified\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
 	return eps;
 err:
 	return ERR_PTR(ret);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified
  2014-02-27 15:42 [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified Alexandre Belloni
@ 2014-02-28 14:35 ` Nicolas Ferre
  2014-03-03 16:46   ` Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Ferre @ 2014-02-28 14:35 UTC (permalink / raw)
  To: Alexandre Belloni, Felipe Balbi
  Cc: linux-kernel, linux-arm-kernel, linux-usb, Greg Kroah-Hartman,
	Maxime Ripard, Gregory Clement

On 27/02/2014 16:42, Alexandre Belloni :
> If no endpoints are present in the device tree, the kernel will cras hwith the

s/cras hwith/crash with/

> following error:
> 
> Unable to handle kernel paging request at virtual address 00101008
> [...]
> [<c0222ff4>] (composite_dev_prepare) from [<c022326c>] (composite_bind+0x5c/0x190)
> [<c022326c>] (composite_bind) from [<c021ff8c>] (udc_bind_to_driver+0x48/0xf0)
> [<c021ff8c>] (udc_bind_to_driver) from [<c02208e0>] (usb_gadget_probe_driver+0x7c/0xa0)
> [<c02208e0>] (usb_gadget_probe_driver) from [<c0008970>] (do_one_initcall+0x94/0x140)
> [<c0008970>] (do_one_initcall) from [<c04b4b50>] (kernel_init_freeable+0xec/0x1b4)
> [<c04b4b50>] (kernel_init_freeable) from [<c0376cc4>] (kernel_init+0x8/0xe4)
> [<c0376cc4>] (kernel_init) from [<c0009590>] (ret_from_fork+0x14/0x24)
> Code: e5950014 e1a04001 e5902008 e3a010d0 (e5922008)
> ---[ end trace 35c74bdd89b373d0 ]---
> Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
> 
> This checks for that case and returns an error, not allowing the driver to be
> loaded with no endpoints.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  drivers/usb/gadget/atmel_usba_udc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index 52771d4c44bc..e3e0c8ff242e 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1914,6 +1914,12 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
>  		i++;
>  	}
>  
> +	if (i == 0) {
> +		dev_err(&pdev->dev, "of_probe: no endpoint specified\n");
> +		ret = -EINVAL;
> +		goto err;
> +	}
> +

It is better for debugging when creating a DT for a new SoC. So, okay.

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

>  	return eps;
>  err:
>  	return ERR_PTR(ret);
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified
  2014-02-28 14:35 ` Nicolas Ferre
@ 2014-03-03 16:46   ` Alexandre Belloni
  2014-03-03 16:47     ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2014-03-03 16:46 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Felipe Balbi, linux-kernel, linux-arm-kernel, linux-usb,
	Greg Kroah-Hartman, Maxime Ripard, Gregory Clement

Hi Felipe,

On 28/02/2014 at 15:35:42 +0100, Nicolas Ferre wrote :
> On 27/02/2014 16:42, Alexandre Belloni :
> > If no endpoints are present in the device tree, the kernel will cras hwith the
> 
> s/cras hwith/crash with/
> 

Do you want me to send a v2 with that typo corrected or could you
correct it when applying ?


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified
  2014-03-03 16:46   ` Alexandre Belloni
@ 2014-03-03 16:47     ` Felipe Balbi
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Balbi @ 2014-03-03 16:47 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Felipe Balbi, linux-kernel, linux-arm-kernel,
	linux-usb, Greg Kroah-Hartman, Maxime Ripard, Gregory Clement

[-- Attachment #1: Type: text/plain, Size: 467 bytes --]

On Mon, Mar 03, 2014 at 05:46:34PM +0100, Alexandre Belloni wrote:
> Hi Felipe,
> 
> On 28/02/2014 at 15:35:42 +0100, Nicolas Ferre wrote :
> > On 27/02/2014 16:42, Alexandre Belloni :
> > > If no endpoints are present in the device tree, the kernel will cras hwith the
> > 
> > s/cras hwith/crash with/
> > 
> 
> Do you want me to send a v2 with that typo corrected or could you
> correct it when applying ?

I'll fix it up, don't worry.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-03 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27 15:42 [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified Alexandre Belloni
2014-02-28 14:35 ` Nicolas Ferre
2014-03-03 16:46   ` Alexandre Belloni
2014-03-03 16:47     ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).