Skip to content

Commit

Permalink
Bluetooth: hidp: Only free input device if failed register
Browse files Browse the repository at this point in the history
When an hidp connection is added for a boot protocol input
device, only free the allocated device if device registration fails.
Subsequent failures should only unregister the device (the input
device api documents that unregister will also free the allocated
device).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Peter Hurley authored and Gustavo F. Padovan committed Aug 11, 2011
1 parent 1c97e94 commit 615aedd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/bluetooth/hidp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ static int hidp_setup_input(struct hidp_session *session,

err = input_register_device(input);
if (err < 0) {
input_free_device(input);
session->input = NULL;
hci_conn_put_device(session->conn);
return err;
}
Expand Down Expand Up @@ -1089,7 +1091,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
failed:
up_write(&hidp_session_sem);

input_free_device(session->input);
kfree(session);
return err;
}
Expand Down

0 comments on commit 615aedd

Please sign in to comment.