lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <18568.29372.218800.510498@harpo.it.uu.se>
Date:	Thu, 24 Jul 2008 14:17:00 +0200
From:	Mikael Pettersson <mikpe@...uu.se>
To:	Ben Dooks <ben-linux@...ff.org>
Cc:	linux-kernel@...r.kernel.org, david-b@...bell.net
Subject: Re: GPIO: Add generic gpio_to_irq call.

Ben Dooks writes:
 > Add gpio_to_irq() implementation allowing the
 > gpio_chip registration to also specify an function
 > to map GPIO offsets into IRQs.
 > 
 > Signed-off-by: Ben Dooks <ben-linux@...ff.org>
 > 
 > Index: linux-2.6.26-quilt3/drivers/gpio/gpiolib.c
 > ===================================================================
 > --- linux-2.6.26-quilt3.orig/drivers/gpio/gpiolib.c	2008-07-18 13:50:32.000000000 +0100
 > +++ linux-2.6.26-quilt3/drivers/gpio/gpiolib.c	2008-07-22 15:20:26.000000000 +0100
 > @@ -339,6 +339,36 @@ const char *gpiochip_is_requested(struct
 >  }
 >  EXPORT_SYMBOL_GPL(gpiochip_is_requested);
 >  
 > +int __gpio_to_irq(unsigned gpio)
 > +{
 > +	struct gpio_chip	*chip;
 > +	struct gpio_desc	*desc = &gpio_desc[gpio];
 > +	unsigned long		flags;
 > +	int			status = -EINVAL;
 > +
 > +	spin_lock_irqsave(&gpio_lock, flags);
 > +
 > +	if (!gpio_is_valid(gpio))
 > +		goto fail;

Please move the &gpio_desc[gpio] expression after the gpio_is_valid(gpio)
test. Otherwise you risk violating C's pointer rules if the gpio is invalid.

 > +
 > +	chip = desc->chip;
 > +	if (!chip || !chip->to_irq)
 > +		goto fail;
 > +
 > +	gpio -= chip->base;
 > +	if (gpio >= chip->ngpio)
 > +		goto fail;
 > +
 > +	status = chip->to_irq(chip, gpio);
 > +
 > + fail:
 > +	spin_unlock_irqrestore(&gpio_lock, flags);
 > +	if (status)
 > +		pr_debug("%s: gpio-%d status %d\n",
 > +			__func__, gpio, status);
 > +	return status;
 > +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ