diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2018-03-05 11:33:21 +0100 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2018-03-15 09:37:20 +0100 |
commit | 97a0c3134f0594389fac704759f83c38ac7d1c17 (patch) | |
tree | 554eedabff929e28b7519d3f81a6e688fbd2e1ce /drivers/mmc | |
parent | e988867fd774d00aeaf5d3c332032bf5b97a4147 (diff) | |
download | linux-97a0c3134f0594389fac704759f83c38ac7d1c17.tar.bz2 |
mmc: core: Use memdup_user() rather than duplicating its implementation
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/block.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 20135a5de748..4b09c7380e70 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -375,22 +375,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); out: |