[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <dffefe927f4d442ac8e205b6ce50ee12eae4e991.1493381776.git.geliangtang@gmail.com>
Date: Sat, 29 Apr 2017 09:45:17 +0800
From: Geliang Tang <geliangtang@...il.com>
To: Jens Axboe <axboe@...com>, Arnd Bergmann <arnd@...db.de>,
Hannes Reinecke <hare@...e.com>,
Johannes Thumshirn <jthumshirn@...e.de>
Cc: Geliang Tang <geliangtang@...il.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] skd_main: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@...il.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
Powered by blists - more mailing lists