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

Marc Kleine-Budde mkl at pengutronix.de
Thu Jan 19 10:11:10 EST 2012


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20120119/083040a7/attachment-0001.sig>


More information about the barebox mailing list