[PATCH 2/9] ARM: at91 gpio: Fix possible null pointer dereference

Sascha Hauer s.hauer at pengutronix.de
Fri Apr 26 16:48:05 EDT 2013


On Fri, Apr 26, 2013 at 06:59:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 20:41 Fri 26 Apr     , Alexander Shiyan wrote:
> > 
> > Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
> > ---
> >  arch/arm/mach-at91/gpio.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
> > index c2618c7..0e39a52 100644
> > --- a/arch/arm/mach-at91/gpio.c
> > +++ b/arch/arm/mach-at91/gpio.c
> > @@ -185,10 +185,10 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = {
> >  int at91_mux_pin(unsigned pin, enum at91_mux mux, int use_pullup)
> >  {
> >  	struct at91_gpio_chip *at91_gpio = pin_to_controller(pin);
> > -	void __iomem *pio = at91_gpio->regbase;
> > +	void __iomem *pio;
> > +	struct device_d *dev;
> >  	unsigned mask = pin_to_mask(pin);
> >  	int bank = pin_to_bank(pin);
> > -	struct device_d *dev = at91_gpio->chip.dev;
> so crash

means what? the original code derefences at91_gpio...

> >  
> >  	if (!at91_gpio)
> >  		return -EINVAL;

...and then checks if at91_gpio is valid which makes no sense.

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 |



More information about the barebox mailing list