Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Use kzalloc instead of kmalloc/memset

Use kzalloc rather than kmalloc followed by memset with 0.

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Wei Yongjun and committed by
Marcel Holtmann
3e36ca48 4037a774

+1 -3
+1 -3
net/bluetooth/mgmt.c
··· 902 902 eir_len = eir_append_data(buff, eir_len, EIR_NAME_SHORT, 903 903 hdev->short_name, name_len); 904 904 905 - rp = kmalloc(sizeof(*rp) + eir_len, GFP_KERNEL); 905 + rp = kzalloc(sizeof(*rp) + eir_len, GFP_KERNEL); 906 906 if (!rp) 907 907 return -ENOMEM; 908 - 909 - memset(rp, 0, sizeof(*rp) + eir_len); 910 908 911 909 rp->eir_len = cpu_to_le16(eir_len); 912 910 memcpy(rp->eir, buff, eir_len);