lkml.org 
[lkml]   [2017]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] skd_main: use memdup_user
Date
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
drivers/block/skd_main.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 27833e4..6b3cdd2 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -1394,22 +1394,16 @@ static int skd_sg_io_get_and_check_args(struct skd_device *skdev,
uint nbytes = sizeof(*iov) * sgp->iovec_count;
size_t iov_data_len;

- iov = kmalloc(nbytes, GFP_KERNEL);
- if (iov == NULL) {
- pr_debug("%s:%s:%d alloc iovec failed %d\n",
+ iov = memdup_user(sgp->dxferp, nbytes);
+ if (IS_ERR(iov)) {
+ pr_debug("%s:%s:%d memdup_user iovec failed %d %p\n",
skdev->name, __func__, __LINE__,
- sgp->iovec_count);
- return -ENOMEM;
+ sgp->iovec_count, sgp->dxferp);
+ return PTR_ERR(iov);
}
sksgio->iov = iov;
sksgio->iovcnt = sgp->iovec_count;

- if (copy_from_user(iov, sgp->dxferp, nbytes)) {
- pr_debug("%s:%s:%d copy_from_user iovec failed %p\n",
- skdev->name, __func__, __LINE__, sgp->dxferp);
- return -EFAULT;
- }
-
/*
* Sum up the vecs, making sure they don't overflow
*/
--
2.9.3
\
 
 \ /
  Last update: 2017-04-29 03:48    [W:0.105 / U:17.312 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site