Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: btmrvl: Re-use kstrtol_from_user()

Re-use kstrtol_from_user() instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Andy Shevchenko and committed by
Marcel Holtmann
c2e7f5de 3bf5e97d

+3 -21
+3 -21
drivers/bluetooth/btmrvl_debugfs.c
··· 35 35 const char __user *ubuf, size_t count, loff_t *ppos) 36 36 { 37 37 struct btmrvl_private *priv = file->private_data; 38 - char buf[16]; 39 38 long result, ret; 40 39 41 - memset(buf, 0, sizeof(buf)); 42 - 43 - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 44 - return -EFAULT; 45 - 46 - ret = kstrtol(buf, 10, &result); 40 + ret = kstrtol_from_user(ubuf, count, 10, &result); 47 41 if (ret) 48 42 return ret; 49 43 ··· 75 81 size_t count, loff_t *ppos) 76 82 { 77 83 struct btmrvl_private *priv = file->private_data; 78 - char buf[16]; 79 84 long result, ret; 80 85 81 - memset(buf, 0, sizeof(buf)); 82 - 83 - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 84 - return -EFAULT; 85 - 86 - ret = kstrtol(buf, 10, &result); 86 + ret = kstrtol_from_user(ubuf, count, 10, &result); 87 87 if (ret) 88 88 return ret; 89 89 ··· 115 127 size_t count, loff_t *ppos) 116 128 { 117 129 struct btmrvl_private *priv = file->private_data; 118 - char buf[16]; 119 130 long result, ret; 120 131 121 - memset(buf, 0, sizeof(buf)); 122 - 123 - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 124 - return -EFAULT; 125 - 126 - ret = kstrtol(buf, 10, &result); 132 + ret = kstrtol_from_user(ubuf, count, 10, &result); 127 133 if (ret) 128 134 return ret; 129 135