[Bluetooth] Remaining transitions to use kzalloc()
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / bluetooth / hidp / core.c
index de8af5f423942750c9677dd86f461366b9f56923..c6e3a2c27c6ecc864dfa85153b1b42f557957f69 100644 (file)
@@ -20,7 +20,6 @@
    SOFTWARE IS DISCLAIMED.
 */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <linux/types.h>
@@ -520,7 +519,7 @@ static int hidp_session(void *arg)
 
        if (session->input) {
                input_unregister_device(session->input);
-               kfree(session->input);
+               session->input = NULL;
        }
 
        up_write(&hidp_session_sem);
@@ -536,6 +535,8 @@ static inline void hidp_setup_input(struct hidp_session *session, struct hidp_co
 
        input->private = session;
 
+       input->name = "Bluetooth HID Boot Protocol Device";
+
        input->id.bustype = BUS_BLUETOOTH;
        input->id.vendor  = req->vendor;
        input->id.product = req->product;
@@ -581,17 +582,15 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
                        bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst))
                return -ENOTUNIQ;
 
-       session = kmalloc(sizeof(struct hidp_session), GFP_KERNEL);
-       if (!session) 
+       session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL);
+       if (!session)
                return -ENOMEM;
-       memset(session, 0, sizeof(struct hidp_session));
 
-       session->input = kmalloc(sizeof(struct input_dev), GFP_KERNEL);
+       session->input = input_allocate_device();
        if (!session->input) {
                kfree(session);
                return -ENOMEM;
        }
-       memset(session->input, 0, sizeof(struct input_dev));
 
        down_write(&hidp_session_sem);
 
@@ -651,15 +650,15 @@ unlink:
 
        __hidp_unlink_session(session);
 
-       if (session->input)
+       if (session->input) {
                input_unregister_device(session->input);
+               session->input = NULL; /* don't try to free it here */
+       }
 
 failed:
        up_write(&hidp_session_sem);
 
-       if (session->input)
-               kfree(session->input);
-
+       kfree(session->input);
        kfree(session);
        return err;
 }