aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2014-03-24 15:08:48 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-03-26 12:31:34 -0400
commit4408dd15d9cfcf78b819d2d4a5b43dc36056cab8 (patch)
tree6a2f1035ceec0615cb8688b120aa58812e229853
parent4af605d8c4d3cf5170fdb40b5c77ea133761d2df (diff)
Bluetooth: Use memdup_user in le_auto_conn_write()
This patch does a small code simplification replacing the tipical kmalloc-copy_from_user sequence by memdup_user() helper. Cc: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_core.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1c6ffaa8902f..bfc6f810554e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -955,14 +955,9 @@ static ssize_t le_auto_conn_write(struct file *file, const char __user *data,
955 if (count < 3) 955 if (count < 3)
956 return -EINVAL; 956 return -EINVAL;
957 957
958 buf = kzalloc(count, GFP_KERNEL); 958 buf = memdup_user(data, count);
959 if (!buf) 959 if (IS_ERR(buf))
960 return -ENOMEM; 960 return PTR_ERR(buf);
961
962 if (copy_from_user(buf, data, count)) {
963 err = -EFAULT;
964 goto done;
965 }
966 961
967 if (memcmp(buf, "add", 3) == 0) { 962 if (memcmp(buf, "add", 3) == 0) {
968 n = sscanf(&buf[4], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu %hhu", 963 n = sscanf(&buf[4], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu %hhu",