Bluetooth: hidp: Only free input device if failed register
authorPeter Hurley <peter@hurleysoftware.com>
Fri, 5 Aug 2011 14:51:50 +0000 (10:51 -0400)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 11 Aug 2011 22:50:28 +0000 (19:50 -0300)
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>
net/bluetooth/hidp/core.c

index 26f0d109ff4194585126510107d39c6ea71a0c24..a859f9078df654bcd5bf59aa91e62e5ca2102a0c 100644 (file)
@@ -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;
        }
@@ -1089,7 +1091,6 @@ purge:
 failed:
        up_write(&hidp_session_sem);
 
-       input_free_device(session->input);
        kfree(session);
        return err;
 }