All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sachin Shukla <sachin.s5@samsung.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	sachiniiitm@gmail.com
Cc: ravikant.s2@samsung.com, p.shailesh@samsung.com,
	ashish.kalra@samsung.com, vidushi.koul@samsung.com
Subject: [PATCH] Fs: Improvement in code readability when memdup_user()fails.
Date: Fri, 11 Nov 2016 14:32:24 +0530	[thread overview]
Message-ID: <1478854944-25969-1-git-send-email-sachin.s5@samsung.com> (raw)

From: "Sachin Shukla"<sachin.s5@samsung.com)>

There is no need to call kfree() if memdup_user() fails, as no memory
was allocated and the error in the error-valued pointer should be returned.

Signed-off-by: Sachin Shukla <sachin.s5@samsung.com>
---
 fs/ioctl.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index c415668..1103c5d 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -588,11 +588,8 @@ static int ioctl_file_dedupe_range(struct file *file, void __user *arg)
 	}
 
 	same = memdup_user(argp, size);
-	if (IS_ERR(same)) {
-		ret = PTR_ERR(same);
-		same = NULL;
-		goto out;
-	}
+	if (IS_ERR(same))
+		return PTR_ERR(same);
 
 	same->dest_count = count;
 	ret = vfs_dedupe_file_range(file, same);
-- 
1.7.9.5

                 reply	other threads:[~2016-11-11  9:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1478854944-25969-1-git-send-email-sachin.s5@samsung.com \
    --to=sachin.s5@samsung.com \
    --cc=ashish.kalra@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.shailesh@samsung.com \
    --cc=ravikant.s2@samsung.com \
    --cc=sachiniiitm@gmail.com \
    --cc=vidushi.koul@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 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.