Bluetooth: MGMT: fix zalloc-simple.cocci warnings
authorYihao Han <hanyihao@vivo.com>
Tue, 20 Sep 2022 03:19:58 +0000 (20:19 -0700)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 20 Sep 2022 22:31:57 +0000 (15:31 -0700)
Use zeroing allocator rather than allocator followed by memset with 0

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

Signed-off-by: Yihao Han <hanyihao@vivo.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/mgmt.c

index b9b64030a7b05fb89a088f8aef595e61a883f7d1..a92e7e485febab36fb6de3525710bdea79025011 100644 (file)
@@ -4397,12 +4397,10 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 
        /* Enough space for 7 features */
        len = sizeof(*rp) + (sizeof(rp->features[0]) * 7);
-       rp = kmalloc(len, GFP_KERNEL);
+       rp = kzalloc(len, GFP_KERNEL);
        if (!rp)
                return -ENOMEM;
 
-       memset(rp, 0, len);
-
 #ifdef CONFIG_BT_FEATURE_DEBUG
        if (!hdev) {
                flags = bt_dbg_get() ? BIT(0) : 0;