Explorar o código

[Bluetooth] Remaining transitions to use kzalloc()

This patch makes the remaining transitions to use kzalloc().

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Marcel Holtmann %!s(int64=19) %!d(string=hai) anos
pai
achega
25ea6db04a

+ 1 - 3
net/bluetooth/cmtp/capi.c

@@ -75,15 +75,13 @@
 
 
 static struct cmtp_application *cmtp_application_add(struct cmtp_session *session, __u16 appl)
 static struct cmtp_application *cmtp_application_add(struct cmtp_session *session, __u16 appl)
 {
 {
-	struct cmtp_application *app = kmalloc(sizeof(*app), GFP_KERNEL);
+	struct cmtp_application *app = kzalloc(sizeof(*app), GFP_KERNEL);
 
 
 	BT_DBG("session %p application %p appl %d", session, app, appl);
 	BT_DBG("session %p application %p appl %d", session, app, appl);
 
 
 	if (!app)
 	if (!app)
 		return NULL;
 		return NULL;
 
 
-	memset(app, 0, sizeof(*app));
-
 	app->state = BT_OPEN;
 	app->state = BT_OPEN;
 	app->appl = appl;
 	app->appl = appl;
 
 

+ 1 - 2
net/bluetooth/cmtp/core.c

@@ -335,10 +335,9 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
 	baswap(&src, &bt_sk(sock->sk)->src);
 	baswap(&src, &bt_sk(sock->sk)->src);
 	baswap(&dst, &bt_sk(sock->sk)->dst);
 	baswap(&dst, &bt_sk(sock->sk)->dst);
 
 
-	session = kmalloc(sizeof(struct cmtp_session), GFP_KERNEL);
+	session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL);
 	if (!session) 
 	if (!session) 
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(session, 0, sizeof(struct cmtp_session));
 
 
 	down_write(&cmtp_session_sem);
 	down_write(&cmtp_session_sem);
 
 

+ 2 - 5
net/bluetooth/hci_core.c

@@ -336,9 +336,8 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data)
 
 
 	if (!(e = hci_inquiry_cache_lookup(hdev, &data->bdaddr))) {
 	if (!(e = hci_inquiry_cache_lookup(hdev, &data->bdaddr))) {
 		/* Entry not in the cache. Add new one. */
 		/* Entry not in the cache. Add new one. */
-		if (!(e = kmalloc(sizeof(struct inquiry_entry), GFP_ATOMIC)))
+		if (!(e = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC)))
 			return;
 			return;
-		memset(e, 0, sizeof(struct inquiry_entry));
 		e->next     = cache->list;
 		e->next     = cache->list;
 		cache->list = e;
 		cache->list = e;
 	}
 	}
@@ -800,12 +799,10 @@ struct hci_dev *hci_alloc_dev(void)
 {
 {
 	struct hci_dev *hdev;
 	struct hci_dev *hdev;
 
 
-	hdev = kmalloc(sizeof(struct hci_dev), GFP_KERNEL);
+	hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL);
 	if (!hdev)
 	if (!hdev)
 		return NULL;
 		return NULL;
 
 
-	memset(hdev, 0, sizeof(struct hci_dev));
-
 	skb_queue_head_init(&hdev->driver_init);
 	skb_queue_head_init(&hdev->driver_init);
 
 
 	return hdev;
 	return hdev;

+ 1 - 2
net/bluetooth/hidp/core.c

@@ -582,10 +582,9 @@ 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))
 			bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst))
 		return -ENOTUNIQ;
 		return -ENOTUNIQ;
 
 
-	session = kmalloc(sizeof(struct hidp_session), GFP_KERNEL);
+	session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL);
 	if (!session)
 	if (!session)
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(session, 0, sizeof(struct hidp_session));
 
 
 	session->input = input_allocate_device();
 	session->input = input_allocate_device();
 	if (!session->input) {
 	if (!session->input) {

+ 5 - 4
net/bluetooth/rfcomm/core.c

@@ -273,10 +273,10 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
 
 
 struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
 struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
 {
 {
-	struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio);
+	struct rfcomm_dlc *d = kzalloc(sizeof(*d), prio);
+
 	if (!d)
 	if (!d)
 		return NULL;
 		return NULL;
-	memset(d, 0, sizeof(*d));
 
 
 	init_timer(&d->timer);
 	init_timer(&d->timer);
 	d->timer.function = rfcomm_dlc_timeout;
 	d->timer.function = rfcomm_dlc_timeout;
@@ -289,6 +289,7 @@ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
 	rfcomm_dlc_clear_state(d);
 	rfcomm_dlc_clear_state(d);
 	
 	
 	BT_DBG("%p", d);
 	BT_DBG("%p", d);
+
 	return d;
 	return d;
 }
 }
 
 
@@ -522,10 +523,10 @@ int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig)
 /* ---- RFCOMM sessions ---- */
 /* ---- RFCOMM sessions ---- */
 static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state)
 static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state)
 {
 {
-	struct rfcomm_session *s = kmalloc(sizeof(*s), GFP_KERNEL);
+	struct rfcomm_session *s = kzalloc(sizeof(*s), GFP_KERNEL);
+
 	if (!s)
 	if (!s)
 		return NULL;
 		return NULL;
-	memset(s, 0, sizeof(*s));
 
 
 	BT_DBG("session %p sock %p", s, sock);
 	BT_DBG("session %p sock %p", s, sock);
 
 

+ 1 - 2
net/bluetooth/rfcomm/tty.c

@@ -169,10 +169,9 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
 
 
 	BT_DBG("id %d channel %d", req->dev_id, req->channel);
 	BT_DBG("id %d channel %d", req->dev_id, req->channel);
 	
 	
-	dev = kmalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
 	if (!dev)
 	if (!dev)
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(dev, 0, sizeof(struct rfcomm_dev));
 
 
 	write_lock_bh(&rfcomm_dev_lock);
 	write_lock_bh(&rfcomm_dev_lock);
 
 

+ 5 - 7
net/bluetooth/sco.c

@@ -108,17 +108,14 @@ static void sco_sock_init_timer(struct sock *sk)
 static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
 static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
 {
 {
 	struct hci_dev *hdev = hcon->hdev;
 	struct hci_dev *hdev = hcon->hdev;
-	struct sco_conn *conn;
-
-	if ((conn = hcon->sco_data))
-		return conn;
+	struct sco_conn *conn = hcon->sco_data;
 
 
-	if (status)
+	if (conn || status)
 		return conn;
 		return conn;
 
 
-	if (!(conn = kmalloc(sizeof(struct sco_conn), GFP_ATOMIC)))
+	conn = kzalloc(sizeof(struct sco_conn), GFP_ATOMIC);
+	if (!conn)
 		return NULL;
 		return NULL;
-	memset(conn, 0, sizeof(struct sco_conn));
 
 
 	spin_lock_init(&conn->lock);
 	spin_lock_init(&conn->lock);
 
 
@@ -134,6 +131,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
 		conn->mtu = 60;
 		conn->mtu = 60;
 
 
 	BT_DBG("hcon %p conn %p", hcon, conn);
 	BT_DBG("hcon %p conn %p", hcon, conn);
+
 	return conn;
 	return conn;
 }
 }