From: Geliang Tang <geliangtang@gmail.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Shawn Lin <shawn.lin@rock-chips.com>, Jens Axboe <axboe@fb.com>
Cc: Geliang Tang <geliangtang@gmail.com>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mmc: block: use memdup_user
Date: Sat, 13 May 2017 11:15:58 +0800 [thread overview]
Message-ID: <b379dcae31767ca644693366c6131304523dcf23.1494578464.git.geliangtang@gmail.com> (raw)
In-Reply-To: <908fa521decaf3703e172c3734c0d498741f3ddb.1494580404.git.geliangtang@gmail.com>
Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
drivers/mmc/core/block.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 8273b07..47ccb2a 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -342,21 +342,15 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
return idata;
}
- idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
- if (!idata->buf) {
- err = -ENOMEM;
+ idata->buf = memdup_user((void __user *)(unsigned long)
+ idata->ic.data_ptr, idata->buf_bytes);
+ if (IS_ERR(idata->buf)) {
+ err = PTR_ERR(idata->buf);
goto idata_err;
}
- if (copy_from_user(idata->buf, (void __user *)(unsigned long)
- idata->ic.data_ptr, idata->buf_bytes)) {
- err = -EFAULT;
- goto copy_err;
- }
-
return idata;
-copy_err:
kfree(idata->buf);
idata_err:
kfree(idata);
--
2.9.3
next prev parent reply other threads:[~2017-05-13 3:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-13 3:15 [PATCH] KEYS: " Geliang Tang
2017-05-13 3:15 ` Geliang Tang [this message]
2017-05-19 7:43 ` [PATCH] mmc: block: " Ulf Hansson
2017-05-13 3:15 ` [PATCH] usb: gadget: f_fs: " Geliang Tang
2017-05-13 8:05 ` Dan Carpenter
2017-05-21 3:25 ` Al Viro
2017-05-14 11:33 ` Michal Nazarewicz
2017-05-13 3:16 ` [PATCH] USB: iowarrior: " Geliang Tang
2017-05-15 10:14 ` Johan Hovold
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=b379dcae31767ca644693366c6131304523dcf23.1494578464.git.geliangtang@gmail.com \
--to=geliangtang@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=axboe@fb.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=ulf.hansson@linaro.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®