mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb/gadget: fix poller NPE in early polling
@ 2012-01-18 20:17 Robert Jarzmik
  2012-01-18 22:56 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Jarzmik @ 2012-01-18 20:17 UTC (permalink / raw)
  To: barebox

The timings of the poller calling have changed, digging out
a latent bug in pxa27x udc controller.
The polling routine is called before the probe function is
called, and the driver internal are not initialized at that
time. This triggers a NULL pointer exception.

Fix it by adding an extra check.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/usb/gadget/pxa27x_udc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index d0dbee9..bde9e74 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1508,7 +1508,10 @@ static struct driver_d udc_driver = {
 
 static int pxa27x_udc_poller(struct poller_struct *poller)
 {
-	return usb_gadget_poll();
+	if (the_controller)
+		return usb_gadget_poll();
+	else
+		return 0;
 }
 static struct poller_struct poller = {
 	.func		= pxa27x_udc_poller
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] usb/gadget: fix poller NPE in early polling
  2012-01-18 20:17 [PATCH] usb/gadget: fix poller NPE in early polling Robert Jarzmik
@ 2012-01-18 22:56 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-01-19 11:23   ` [PATCH V2] " Robert Jarzmik
  0 siblings, 1 reply; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-01-18 22:56 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox

On 21:17 Wed 18 Jan     , Robert Jarzmik wrote:
> The timings of the poller calling have changed, digging out
> a latent bug in pxa27x udc controller.
> The polling routine is called before the probe function is
> called, and the driver internal are not initialized at that
> time. This triggers a NULL pointer exception.
> 
> Fix it by adding an extra check.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---
>  drivers/usb/gadget/pxa27x_udc.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
> index d0dbee9..bde9e74 100644
> --- a/drivers/usb/gadget/pxa27x_udc.c
> +++ b/drivers/usb/gadget/pxa27x_udc.c
> @@ -1508,7 +1508,10 @@ static struct driver_d udc_driver = {
>  
>  static int pxa27x_udc_poller(struct poller_struct *poller)
>  {
> -	return usb_gadget_poll();
> +	if (the_controller)
> +		return usb_gadget_poll();
> +	else
> +		return 0;
>  }
instead of this register thee poll at the probe

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH V2] usb/gadget: fix poller NPE in early polling
  2012-01-18 22:56 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-01-19 11:23   ` Robert Jarzmik
  2012-01-19 15:11     ` Marc Kleine-Budde
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Jarzmik @ 2012-01-19 11:23 UTC (permalink / raw)
  To: barebox, plagnioj

The timings of the poller calling have changed, digging out
a latent bug in pxa27x udc controller.
The polling routine is called before the probe function is
called, and the driver internal are not initialized at that
time. This triggers a NULL pointer exception.

Fix it by moving poller registration after driver probe.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

---
Since V1: Review by Jean-Christophe
---
 drivers/usb/gadget/pxa27x_udc.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index d0dbee9..10483c5 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1473,6 +1473,14 @@ static struct pxa_udc memory = {
 	}
 };
 
+static int pxa27x_udc_poller(struct poller_struct *poller)
+{
+		return usb_gadget_poll();
+}
+static struct poller_struct poller = {
+	.func		= pxa27x_udc_poller
+};
+
 static int __init pxa_udc_probe(struct device_d *dev)
 {
 	struct pxa_udc *udc = &memory;
@@ -1496,6 +1504,8 @@ static int __init pxa_udc_probe(struct device_d *dev)
 	the_controller = udc;
 	udc_init_data(udc);
 	pxa_eps_setup(udc);
+	poller_register(&poller);
+
 	return 0;
 }
 
@@ -1506,18 +1516,9 @@ static struct driver_d udc_driver = {
 	.probe		= pxa_udc_probe,
 };
 
-static int pxa27x_udc_poller(struct poller_struct *poller)
-{
-	return usb_gadget_poll();
-}
-static struct poller_struct poller = {
-	.func		= pxa27x_udc_poller
-};
-
 static int __init pxa27x_udc_init(void)
 {
 	register_driver(&udc_driver);
-	poller_register(&poller);
 	return 0;
 }
 
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH V2] usb/gadget: fix poller NPE in early polling
  2012-01-19 11:23   ` [PATCH V2] " Robert Jarzmik
@ 2012-01-19 15:11     ` Marc Kleine-Budde
  2012-01-20 20:17       ` [PATCH V3] " Robert Jarzmik
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Kleine-Budde @ 2012-01-19 15:11 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2174 bytes --]

On 01/19/2012 12:23 PM, Robert Jarzmik wrote:
> The timings of the poller calling have changed, digging out
> a latent bug in pxa27x udc controller.
> The polling routine is called before the probe function is
> called, and the driver internal are not initialized at that
> time. This triggers a NULL pointer exception.
> 
> Fix it by moving poller registration after driver probe.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> 
> ---
> Since V1: Review by Jean-Christophe
> ---
>  drivers/usb/gadget/pxa27x_udc.c |   19 ++++++++++---------
>  1 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
> index d0dbee9..10483c5 100644
> --- a/drivers/usb/gadget/pxa27x_udc.c
> +++ b/drivers/usb/gadget/pxa27x_udc.c
> @@ -1473,6 +1473,14 @@ static struct pxa_udc memory = {
>  	}
>  };
>  
> +static int pxa27x_udc_poller(struct poller_struct *poller)
> +{
> +		return usb_gadget_poll();

one tab should be enough.

> +}
> +static struct poller_struct poller = {
> +	.func		= pxa27x_udc_poller
> +};
> +
>  static int __init pxa_udc_probe(struct device_d *dev)
>  {
>  	struct pxa_udc *udc = &memory;
> @@ -1496,6 +1504,8 @@ static int __init pxa_udc_probe(struct device_d *dev)
>  	the_controller = udc;
>  	udc_init_data(udc);
>  	pxa_eps_setup(udc);
> +	poller_register(&poller);
> +
>  	return 0;
>  }
>  
> @@ -1506,18 +1516,9 @@ static struct driver_d udc_driver = {
>  	.probe		= pxa_udc_probe,
>  };
>  
> -static int pxa27x_udc_poller(struct poller_struct *poller)
> -{
> -	return usb_gadget_poll();
> -}
> -static struct poller_struct poller = {
> -	.func		= pxa27x_udc_poller
> -};
> -
>  static int __init pxa27x_udc_init(void)
>  {
>  	register_driver(&udc_driver);
> -	poller_register(&poller);
>  	return 0;
>  }
>  

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH V3] usb/gadget: fix poller NPE in early polling
  2012-01-19 15:11     ` Marc Kleine-Budde
@ 2012-01-20 20:17       ` Robert Jarzmik
  2012-01-23  8:48         ` Sascha Hauer
  2012-01-23 10:38         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 8+ messages in thread
From: Robert Jarzmik @ 2012-01-20 20:17 UTC (permalink / raw)
  To: barebox, plagnioj, mkl

The timings of the poller calling have changed, digging out
a latent bug in pxa27x udc controller.
The polling routine is called before the probe function is
called, and the driver internal are not initialized at that
time. This triggers a NULL pointer exception.

Fix it by moving poller registration after driver probe.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

---
Since V1: Review by Jean-Christophe
Since V2: Remove a tab
---
 drivers/usb/gadget/pxa27x_udc.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index d0dbee9..5652555 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1473,6 +1473,14 @@ static struct pxa_udc memory = {
 	}
 };
 
+static int pxa27x_udc_poller(struct poller_struct *poller)
+{
+	return usb_gadget_poll();
+}
+static struct poller_struct poller = {
+	.func		= pxa27x_udc_poller
+};
+
 static int __init pxa_udc_probe(struct device_d *dev)
 {
 	struct pxa_udc *udc = &memory;
@@ -1496,6 +1504,8 @@ static int __init pxa_udc_probe(struct device_d *dev)
 	the_controller = udc;
 	udc_init_data(udc);
 	pxa_eps_setup(udc);
+	poller_register(&poller);
+
 	return 0;
 }
 
@@ -1506,18 +1516,9 @@ static struct driver_d udc_driver = {
 	.probe		= pxa_udc_probe,
 };
 
-static int pxa27x_udc_poller(struct poller_struct *poller)
-{
-	return usb_gadget_poll();
-}
-static struct poller_struct poller = {
-	.func		= pxa27x_udc_poller
-};
-
 static int __init pxa27x_udc_init(void)
 {
 	register_driver(&udc_driver);
-	poller_register(&poller);
 	return 0;
 }
 
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH V3] usb/gadget: fix poller NPE in early polling
  2012-01-20 20:17       ` [PATCH V3] " Robert Jarzmik
@ 2012-01-23  8:48         ` Sascha Hauer
  2012-01-23 16:25           ` Robert Jarzmik
  2012-01-23 10:38         ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2012-01-23  8:48 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox

Hi Robert,

On Fri, Jan 20, 2012 at 09:17:24PM +0100, Robert Jarzmik wrote:
> The timings of the poller calling have changed, digging out
> a latent bug in pxa27x udc controller.
> The polling routine is called before the probe function is
> called, and the driver internal are not initialized at that
> time. This triggers a NULL pointer exception.
> 
> Fix it by moving poller registration after driver probe.

Please specifiy for which branch this is targeted next time. I was
about to apply it for next until I realized that this breakage is
already in master.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH V3] usb/gadget: fix poller NPE in early polling
  2012-01-20 20:17       ` [PATCH V3] " Robert Jarzmik
  2012-01-23  8:48         ` Sascha Hauer
@ 2012-01-23 10:38         ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-01-23 10:38 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox

On 21:17 Fri 20 Jan     , Robert Jarzmik wrote:
> The timings of the poller calling have changed, digging out
> a latent bug in pxa27x udc controller.
> The polling routine is called before the probe function is
> called, and the driver internal are not initialized at that
> time. This triggers a NULL pointer exception.
> 
> Fix it by moving poller registration after driver probe.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> 
> ---
looks good

Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH V3] usb/gadget: fix poller NPE in early polling
  2012-01-23  8:48         ` Sascha Hauer
@ 2012-01-23 16:25           ` Robert Jarzmik
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Jarzmik @ 2012-01-23 16:25 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Sascha Hauer <s.hauer@pengutronix.de> writes:
> Please specifiy for which branch this is targeted next time. I was
> about to apply it for next until I realized that this breakage is
> already in master.
OK.

Cheers.

-- 
Robert

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-01-23 16:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18 20:17 [PATCH] usb/gadget: fix poller NPE in early polling Robert Jarzmik
2012-01-18 22:56 ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-19 11:23   ` [PATCH V2] " Robert Jarzmik
2012-01-19 15:11     ` Marc Kleine-Budde
2012-01-20 20:17       ` [PATCH V3] " Robert Jarzmik
2012-01-23  8:48         ` Sascha Hauer
2012-01-23 16:25           ` Robert Jarzmik
2012-01-23 10:38         ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox