From: Sachin Shukla <sachin.s5@samsung.com>
To: Jens Axboe <axboe@fb.com>,
Asai Thambi SP <asamymuthupa@micron.com>,
Selvan Mani <smani@micron.com>,
Rajesh Kumar Sambandam <rsambandam@micron.com>,
Vignesh Gunasekaran <vgunasekaran@micron.com>,
Al Viro <viro@zeniv.linux.org.uk>,
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] Block: mtip32xx: Improvement in code readability when memdup_user() fails.
Date: Fri, 11 Nov 2016 14:34:51 +0530 [thread overview]
Message-ID: <1478855091-26096-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>
---
drivers/block/mtip32xx/mtip32xx.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 3cfd879..68e332b 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2035,18 +2035,14 @@ static int exec_drive_taskfile(struct driver_data *dd,
taskout = req_task->out_size;
taskin = req_task->in_size;
/* 130560 = 512 * 0xFF*/
- if (taskin > 130560 || taskout > 130560) {
- err = -EINVAL;
- goto abort;
- }
+ if (taskin > 130560 || taskout > 130560)
+ return -EINVAL;
if (taskout) {
outbuf = memdup_user(buf + outtotal, taskout);
- if (IS_ERR(outbuf)) {
- err = PTR_ERR(outbuf);
- outbuf = NULL;
- goto abort;
- }
+ if (IS_ERR(outbuf))
+ return PTR_ERR(outbuf);
+
outbuf_dma = pci_map_single(dd->pdev,
outbuf,
taskout,
--
1.7.9.5
next reply other threads:[~2016-11-11 9:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 9:04 Sachin Shukla [this message]
2016-11-11 20:37 ` [PATCH] Block: mtip32xx: Improvement in code readability when memdup_user() fails Jens Axboe
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=1478855091-26096-1-git-send-email-sachin.s5@samsung.com \
--to=sachin.s5@samsung.com \
--cc=asamymuthupa@micron.com \
--cc=ashish.kalra@samsung.com \
--cc=axboe@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=p.shailesh@samsung.com \
--cc=ravikant.s2@samsung.com \
--cc=rsambandam@micron.com \
--cc=sachiniiitm@gmail.com \
--cc=smani@micron.com \
--cc=vgunasekaran@micron.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).