From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RoKu5-0003ar-Md for barebox@lists.infradead.org; Fri, 20 Jan 2012 20:17:43 +0000 From: Robert Jarzmik Date: Fri, 20 Jan 2012 21:17:24 +0100 Message-Id: <1327090644-17469-1-git-send-email-robert.jarzmik@free.fr> In-Reply-To: <4F18328E.9080404@pengutronix.de> References: <4F18328E.9080404@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH V3] usb/gadget: fix poller NPE in early polling To: barebox@lists.infradead.org, plagnioj@jcrosoft.com, mkl@pengutronix.de 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 --- 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