lkml.org 
[lkml]   [2019]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4.14 28/35] uio: Reduce return paths from uio_write()
Date
4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Hamish Martin <hamish.martin@alliedtelesis.co.nz>

commit 81daa406c2cc97d85eef9409400404efc2a3f756 upstream.

Drive all return paths for uio_write() through a single block at the
end of the function.

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/uio/uio.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)

--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -570,20 +570,29 @@ static ssize_t uio_write(struct file *fi
ssize_t retval;
s32 irq_on;

- if (!idev->info->irq)
- return -EIO;
-
- if (count != sizeof(s32))
- return -EINVAL;
-
- if (!idev->info->irqcontrol)
- return -ENOSYS;
-
- if (copy_from_user(&irq_on, buf, count))
- return -EFAULT;
+ if (!idev->info->irq) {
+ retval = -EIO;
+ goto out;
+ }
+
+ if (count != sizeof(s32)) {
+ retval = -EINVAL;
+ goto out;
+ }
+
+ if (!idev->info->irqcontrol) {
+ retval = -ENOSYS;
+ goto out;
+ }
+
+ if (copy_from_user(&irq_on, buf, count)) {
+ retval = -EFAULT;
+ goto out;
+ }

retval = idev->info->irqcontrol(idev->info, irq_on);

+out:
return retval ? retval : sizeof(s32);
}


\
 
 \ /
  Last update: 2019-02-13 19:55    [W:0.160 / U:0.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site