All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] gpiolib: potential oops on failure path
@ 2016-06-17  9:15 ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2016-06-17  9:15 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio, kernel-janitors

If anon_inode_getfd() fails then "i" is set to GPIOHANDLES_MAX.  It
means that we will read beyond the end of the array and dereference an
invalid pointer.

Fixes: d7c51b47ac11 ('gpio: userspace ABI for reading/writing GPIO lines')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8b3db59..8578b7f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -495,6 +495,8 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
 	return 0;
 
 out_free_descs:
+	if (i = GPIOHANDLES_MAX)
+		i--;
 	for (; i >= 0; i--)
 		gpiod_free(lh->descs[i]);
 	kfree(lh->label);

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-06-18  8:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17  9:15 [patch] gpiolib: potential oops on failure path Dan Carpenter
2016-06-17  9:15 ` Dan Carpenter
2016-06-17  9:28 ` walter harms
2016-06-17  9:28   ` walter harms
2016-06-17  9:59   ` Dan Carpenter
2016-06-17  9:59     ` Dan Carpenter
2016-06-18  8:54   ` Linus Walleij
2016-06-18  8:54     ` Linus Walleij
2016-06-18  8:52 ` Linus Walleij
2016-06-18  8:52   ` Linus Walleij
2016-06-18  8:57   ` Linus Walleij
2016-06-18  8:57     ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.