mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rantala, Tommi T. (Nokia - FI/Espoo)" <tommi.t.rantala@nokia.com>
To: "stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Hamish Martin <hamish.martin@alliedtelesis.co.nz>,
	Chris Packham <chris.packham@alliedtelesis.co.nz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rantala,
	Tommi T. (Nokia - FI/Espoo)" <tommi.t.rantala@nokia.com>
Subject: [PATCH 4.14 1/8] uio: Reduce return paths from uio_write()
Date: Wed, 13 Feb 2019 16:29:24 +0000	[thread overview]
Message-ID: <20190213162845.11688-2-tommi.t.rantala@nokia.com> (raw)
In-Reply-To: <20190213162845.11688-1-tommi.t.rantala@nokia.com>

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>
---
 drivers/uio/uio.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 654579bc1e54..10f249628e79 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -570,20 +570,29 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
 	ssize_t retval;
 	s32 irq_on;
 
-	if (!idev->info->irq)
-		return -EIO;
+	if (!idev->info->irq) {
+		retval = -EIO;
+		goto out;
+	}
 
-	if (count != sizeof(s32))
-		return -EINVAL;
+	if (count != sizeof(s32)) {
+		retval = -EINVAL;
+		goto out;
+	}
 
-	if (!idev->info->irqcontrol)
-		return -ENOSYS;
+	if (!idev->info->irqcontrol) {
+		retval = -ENOSYS;
+		goto out;
+	}
 
-	if (copy_from_user(&irq_on, buf, count))
-		return -EFAULT;
+	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);
 }
 
-- 
2.20.1


  reply	other threads:[~2019-02-13 16:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 16:29 [PATCH 4.14 0/8] uio backport fixes for 4.14 Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` Rantala, Tommi T. (Nokia - FI/Espoo) [this message]
2019-02-13 16:29 ` [PATCH 4.14 2/8] uio: Prevent device destruction while fds are open Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` [PATCH 4.14 3/8] uio: use request_threaded_irq instead Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` [PATCH 4.14 4/8] uio: change to use the mutex lock instead of the spin lock Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` [PATCH 4.14 5/8] uio: fix crash after the device is unregistered Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` [PATCH 4.14 7/8] uio: fix possible circular locking dependency Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` [PATCH 4.14 6/8] uio: fix wrong return value from uio_mmap() Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 16:29 ` [PATCH 4.14 8/8] Revert "uio: use request_threaded_irq instead" Rantala, Tommi T. (Nokia - FI/Espoo)
2019-02-13 18:36 ` [PATCH 4.14 0/8] uio backport fixes for 4.14 Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213162845.11688-2-tommi.t.rantala@nokia.com \
    --to=tommi.t.rantala@nokia.com \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=gregkh@linuxfoundation.org \
    --cc=hamish.martin@alliedtelesis.co.nz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®