mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Felipe Balbi <balbi@ti.com>, "Du, Changbin" <changbin.du@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Robert Baldyga <r.baldyga@samsung.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Michal Nazarewicz <mina86@mina86.com>
Subject: [PATCH 3/5] usb: f_fs: replace unnecessary goto with a return
Date: Mon,  4 Jan 2016 22:41:39 +0100	[thread overview]
Message-ID: <1451943701-18212-3-git-send-email-mina86@mina86.com> (raw)
In-Reply-To: <1451943701-18212-1-git-send-email-mina86@mina86.com>

In ffs_epfile_io error label points to a return path which includes
a kfree(data) call.  However, at the beginning of the function data is
always NULL so some of the early ‘goto error’ can safely be replaced
with a trivial return statement.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
 drivers/usb/gadget/function/f_fs.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 1384220..c4e6395 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -690,32 +690,24 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
 	int halt;
 
 	/* Are we still active? */
-	if (WARN_ON(epfile->ffs->state != FFS_ACTIVE)) {
-		ret = -ENODEV;
-		goto error;
-	}
+	if (WARN_ON(epfile->ffs->state != FFS_ACTIVE))
+		return -ENODEV;
 
 	/* Wait for endpoint to be enabled */
 	ep = epfile->ep;
 	if (!ep) {
-		if (file->f_flags & O_NONBLOCK) {
-			ret = -EAGAIN;
-			goto error;
-		}
+		if (file->f_flags & O_NONBLOCK)
+			return -EAGAIN;
 
 		ret = wait_event_interruptible(epfile->wait, (ep = epfile->ep));
-		if (ret) {
-			ret = -EINTR;
-			goto error;
-		}
+		if (ret)
+			return -EINTR;
 	}
 
 	/* Do we halt? */
 	halt = (!io_data->read == !epfile->in);
-	if (halt && epfile->isoc) {
-		ret = -EINVAL;
-		goto error;
-	}
+	if (halt && epfile->isoc)
+		return -EINVAL;
 
 	/* Allocate & copy */
 	if (!halt) {
-- 
2.6.0.rc2.230.g3dd15c0


  parent reply	other threads:[~2016-01-04 21:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 21:41 [PATCH 1/5] usb: f_fs: fix memory leak when ep changes during transfer Michal Nazarewicz
2016-01-04 21:41 ` [PATCH 2/5] usb: f_fs: fix ffs_epfile_io returning success on req alloc failure Michal Nazarewicz
2016-01-04 21:41 ` Michal Nazarewicz [this message]
2016-01-04 21:41 ` [PATCH 4/5] usb: f_fs: refactor ffs_epfile_io Michal Nazarewicz
2016-01-04 21:41 ` [PATCH 5/5] usb: f_fs: avoid race condition with ffs_epfile_io_complete Michal Nazarewicz

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=1451943701-18212-3-git-send-email-mina86@mina86.com \
    --to=mina86@mina86.com \
    --cc=balbi@ti.com \
    --cc=changbin.du@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=r.baldyga@samsung.com \
    --cc=viro@zeniv.linux.org.uk \
    /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®