Skip to content

Commit 615aedd

Browse files
peterhurleyGustavo F. Padovan
authored andcommitted
Bluetooth: hidp: Only free input device if failed register
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>
1 parent 1c97e94 commit 615aedd

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/bluetooth/hidp/core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,8 @@ static int hidp_setup_input(struct hidp_session *session,
842842

843843
err = input_register_device(input);
844844
if (err < 0) {
845+
input_free_device(input);
846+
session->input = NULL;
845847
hci_conn_put_device(session->conn);
846848
return err;
847849
}
@@ -1089,7 +1091,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
10891091
failed:
10901092
up_write(&hidp_session_sem);
10911093

1092-
input_free_device(session->input);
10931094
kfree(session);
10941095
return err;
10951096
}

0 commit comments

Comments
 (0)