aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-07-04 07:13:04 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-07-04 10:54:36 -0400
commitd932cd49182f97966d196fb5301bfca90f58a360 (patch)
tree9a94e87c0723413c4a6319fa080e02bffdcee003 /drivers/gpio/gpiolib.c
parenta944a892aa8ddecf6e2df432e6965dc86d73e3aa (diff)
gpio: free handles in fringe cases
If we fail when copying the ioctl() struct to userspace we still need to clean up the cruft otherwise left behind or it will stay around until the issuing process terminates the file handle. Reported-by: Alexander Stein <alexander.stein@systec-electronic.com> Acked-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b195ec406ff4..69efe278f74d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -488,8 +488,10 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
488 } 488 }
489 489
490 handlereq.fd = fd; 490 handlereq.fd = fd;
491 if (copy_to_user(ip, &handlereq, sizeof(handlereq))) 491 if (copy_to_user(ip, &handlereq, sizeof(handlereq))) {
492 return -EFAULT; 492 ret = -EFAULT;
493 goto out_free_descs;
494 }
493 495
494 dev_dbg(&gdev->dev, "registered chardev handle for %d lines\n", 496 dev_dbg(&gdev->dev, "registered chardev handle for %d lines\n",
495 lh->numdescs); 497 lh->numdescs);
@@ -784,8 +786,10 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
784 } 786 }
785 787
786 eventreq.fd = fd; 788 eventreq.fd = fd;
787 if (copy_to_user(ip, &eventreq, sizeof(eventreq))) 789 if (copy_to_user(ip, &eventreq, sizeof(eventreq))) {
788 return -EFAULT; 790 ret = -EFAULT;
791 goto out_free_irq;
792 }
789 793
790 return 0; 794 return 0;
791 795