diff options
author | Roland Dreier <roland@purestorage.com> | 2012-07-27 16:27:45 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2012-07-27 16:27:45 -0400 |
commit | 0764c76ecb06987749bce49657e473e6605f09c4 (patch) | |
tree | a756c573941b8a533e49441fb92da49f13cc5559 /drivers/infiniband | |
parent | 4e289045286c5f20d7d8f86b18679bad9e9a2003 (diff) |
RDMA/ucma: Convert open-coded equivalent to memdup_user()
Suggested by scripts/coccinelle/api/memdup_user.cocci.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/ucma.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 893cb879462c..6bf850422895 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
@@ -1002,23 +1002,18 @@ static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf, | |||
1002 | if (IS_ERR(ctx)) | 1002 | if (IS_ERR(ctx)) |
1003 | return PTR_ERR(ctx); | 1003 | return PTR_ERR(ctx); |
1004 | 1004 | ||
1005 | optval = kmalloc(cmd.optlen, GFP_KERNEL); | 1005 | optval = memdup_user((void __user *) (unsigned long) cmd.optval, |
1006 | if (!optval) { | 1006 | cmd.optlen); |
1007 | ret = -ENOMEM; | 1007 | if (IS_ERR(optval)) { |
1008 | goto out1; | 1008 | ret = PTR_ERR(optval); |
1009 | } | 1009 | goto out; |
1010 | |||
1011 | if (copy_from_user(optval, (void __user *) (unsigned long) cmd.optval, | ||
1012 | cmd.optlen)) { | ||
1013 | ret = -EFAULT; | ||
1014 | goto out2; | ||
1015 | } | 1010 | } |
1016 | 1011 | ||
1017 | ret = ucma_set_option_level(ctx, cmd.level, cmd.optname, optval, | 1012 | ret = ucma_set_option_level(ctx, cmd.level, cmd.optname, optval, |
1018 | cmd.optlen); | 1013 | cmd.optlen); |
1019 | out2: | ||
1020 | kfree(optval); | 1014 | kfree(optval); |
1021 | out1: | 1015 | |
1016 | out: | ||
1022 | ucma_put_ctx(ctx); | 1017 | ucma_put_ctx(ctx); |
1023 | return ret; | 1018 | return ret; |
1024 | } | 1019 | } |