]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/bluetooth/hidp/core.c
Bluetooth: hidp: replace kzalloc/copy_from_user by memdup_user
[mirror_ubuntu-bionic-kernel.git] / net / bluetooth / hidp / core.c
index 1b7d605706aa5720b45e056d3a75f235c9c4ab60..cc25d0b74b3609ef800453484eef7e0f55767162 100644 (file)
@@ -736,14 +736,10 @@ static int hidp_setup_hid(struct hidp_session *session,
        struct hid_device *hid;
        int err;
 
-       session->rd_data = kzalloc(req->rd_size, GFP_KERNEL);
-       if (!session->rd_data)
-               return -ENOMEM;
+       session->rd_data = memdup_user(req->rd_data, req->rd_size);
+       if (IS_ERR(session->rd_data))
+               return PTR_ERR(session->rd_data);
 
-       if (copy_from_user(session->rd_data, req->rd_data, req->rd_size)) {
-               err = -EFAULT;
-               goto fault;
-       }
        session->rd_size = req->rd_size;
 
        hid = hid_allocate_device();