Skip to contentSkip to conversation

Bluetooth: Use zalloc when possible

PATCH In review Johan Hedberg 2 participants 2 messages Jun 18, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Use zalloc when possible

From: Johan Hedberg <[email protected]>

Use zallog for adv_instance allocation instead of kmalloc + memset. This also fixes the following coccinelle warning:

Quoted 1 line
Quoted 1 line

net/bluetooth/hci_core.c:2693:17-24: WARNING: kzalloc should be

used for adv_instance, instead of kmalloc/memset

---
 net/bluetooth/hci_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/bluetooth/hci_core.c +1 -2
index 86ed44e39649..2f8fb33067e1 100644
@@ -2716,11 +2716,10 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
 		    instance < 1 || instance > HCI_MAX_ADV_INSTANCES)
 			return -EOVERFLOW;
 
-		adv_instance = kmalloc(sizeof(*adv_instance), GFP_KERNEL);
+		adv_instance = kzalloc(sizeof(*adv_instance), GFP_KERNEL);
 		if (!adv_instance)
 			return -ENOMEM;
 
-		memset(adv_instance, 0, sizeof(*adv_instance));
 		adv_instance->pending = true;
 		adv_instance->instance = instance;
 		list_add(&adv_instance->list, &hdev->adv_instances);
Signature · 1 line
2.4.3
maintainer
#1 lore raw

Hi Johan,

Quoted 10 lines

Use zallog for adv_instance allocation instead of kmalloc + memset. This also fixes the following coccinelle warning:

Quoted 1 line
Quoted 1 line

net/bluetooth/hci_core.c:2693:17-24: WARNING: kzalloc should be

used for adv_instance, instead of kmalloc/memset

---
net/bluetooth/hci_core.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel