diff options
| author | Vasyl Gomonovych <gomonovych@gmail.com> | 2017-11-22 10:25:30 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-12-07 12:45:31 -0500 |
| commit | 30b7a2c19e296fc4b8a9a21d67752d8dd55bc7dc (patch) | |
| tree | 6e20370f3d7d53d2d30531f210d9b0c0edd0f861 /drivers/misc/mic | |
| parent | eecf4f9dd940fc90b38693ec6cde9badf0bea56a (diff) | |
misc: mic: Use memdup_user() as a cleanup
Fix coccicheck warning which recommends to use memdup_user():
drivers/misc/mic/vop/vop_vringh.c:940:14-21: WARNING opportunity for memdup_user
drivers/misc/mic/vop/vop_vringh.c:998:8-15: WARNING opportunity for memdup_user
Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci
Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mic')
| -rw-r--r-- | drivers/misc/mic/vop/vop_vringh.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c index fed992e2c258..bde0305ebd91 100644 --- a/drivers/misc/mic/vop/vop_vringh.c +++ b/drivers/misc/mic/vop/vop_vringh.c | |||
| @@ -937,13 +937,10 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | |||
| 937 | dd.num_vq > MIC_MAX_VRINGS) | 937 | dd.num_vq > MIC_MAX_VRINGS) |
| 938 | return -EINVAL; | 938 | return -EINVAL; |
| 939 | 939 | ||
| 940 | dd_config = kzalloc(mic_desc_size(&dd), GFP_KERNEL); | 940 | dd_config = memdup_user(argp, mic_desc_size(&dd)); |
| 941 | if (!dd_config) | 941 | if (IS_ERR(dd_config)) |
| 942 | return -ENOMEM; | 942 | return PTR_ERR(dd_config); |
| 943 | if (copy_from_user(dd_config, argp, mic_desc_size(&dd))) { | 943 | |
| 944 | ret = -EFAULT; | ||
| 945 | goto free_ret; | ||
| 946 | } | ||
| 947 | /* Ensure desc has not changed between the two reads */ | 944 | /* Ensure desc has not changed between the two reads */ |
| 948 | if (memcmp(&dd, dd_config, sizeof(dd))) { | 945 | if (memcmp(&dd, dd_config, sizeof(dd))) { |
| 949 | ret = -EINVAL; | 946 | ret = -EINVAL; |
| @@ -995,15 +992,11 @@ _unlock_ret: | |||
| 995 | ret = vop_vdev_inited(vdev); | 992 | ret = vop_vdev_inited(vdev); |
| 996 | if (ret) | 993 | if (ret) |
| 997 | goto __unlock_ret; | 994 | goto __unlock_ret; |
| 998 | buf = kzalloc(vdev->dd->config_len, GFP_KERNEL); | 995 | buf = memdup_user(argp, vdev->dd->config_len); |
| 999 | if (!buf) { | 996 | if (IS_ERR(buf)) { |
| 1000 | ret = -ENOMEM; | 997 | ret = PTR_ERR(buf); |
| 1001 | goto __unlock_ret; | 998 | goto __unlock_ret; |
| 1002 | } | 999 | } |
| 1003 | if (copy_from_user(buf, argp, vdev->dd->config_len)) { | ||
| 1004 | ret = -EFAULT; | ||
| 1005 | goto done; | ||
| 1006 | } | ||
| 1007 | ret = vop_virtio_config_change(vdev, buf); | 1000 | ret = vop_virtio_config_change(vdev, buf); |
| 1008 | done: | 1001 | done: |
| 1009 | kfree(buf); | 1002 | kfree(buf); |
