[PATCH] usb/gadget: fix poller NPE in early polling

Robert Jarzmik robert.jarzmik at free.fr
Wed Jan 18 15:17:39 EST 2012


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 at 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




More information about the barebox mailing list