Skip to content

Commit

Permalink
Bluetooth: hidp: replace kzalloc/copy_from_user by memdup_user
Browse files Browse the repository at this point in the history
use memdup_user for rd_data import.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Fabian Frederick authored and Marcel Holtmann committed Nov 15, 2014
1 parent 2773b02 commit a809eff
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions net/bluetooth/hidp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a809eff

Please sign in to comment.