Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3854164rwi; Sun, 16 Oct 2022 20:07:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41NGy65OcSBE/0gUWKK2/XxJNNaRVXXBYR7vLvyPKLpTcu24o1QOtZl4WS/JLeoqCnz6X5 X-Received: by 2002:a17:902:8f91:b0:184:d3ed:afd8 with SMTP id z17-20020a1709028f9100b00184d3edafd8mr9949675plo.15.1665976020879; Sun, 16 Oct 2022 20:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665976020; cv=none; d=google.com; s=arc-20160816; b=T2bd6epM4aXP0RW8VQZTtEsPdLIIoTniEZD6cT5WWXjWmasM/Kw7tx9MB5Ko77H0iy xG9OjETNt3kreGBYkdkRFKgdxJ76m9pirbF/YfyHnmeIBLeUBeX6yZCDQqqar3IF2E1s 2tGUATRSBiLJLzY5qHaNpXad/gRIWvizkwqlzjBbO6lc8qgVmNu91xgBxC4WQy6mgMkx EavBRZAIt9gSonWMLGSf6RyZmasTzzah7L7HBLxeNx37yPhxQq26G9P79ca7Nxz6/DUF 421yCmFJi/7DLvTwpx/QewjYdMfWu0mUX4RVhASEQvMgG7Ad7oWxkRp9XnwJViDsv3wh Vqiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=mjLmgnSBE+hYiuHVzgY9LIQyHmq+IT1oTYrK/FxZmU4=; b=aDer9sJG+GFPyvaH7wyISFVmGR6sX03VTdKOdMcjDQIvMgULve1X21FaJAL7vK6+7W urVErUYRqK0iy681BxA/LxuEZzc+Z5EqgA5ZL7WZ3EVZRMqVE7+JboO6V+poWlLzY/OP PFpTzDWjmXEIDPyAxL7X1RqngyRp5f3uye/rmNRm4/80ODH44Va46vAx3VLWyMFdBUPz p98578G+v2SmlaYiQ1P5XLNyBkDs0DOeGRUC91WmIp8Ux9yS/MqguuZNgCKdHIX4fcjb iXkPaEPLiFOnsiYbSnPAYWhQE3K9mqjYrSljzNh5zLkXayXfiIG2L9WjMAXmAXNIlttA xOSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i187-20020a6254c4000000b0056301324a24si9897632pfb.133.2022.10.16.20.06.35; Sun, 16 Oct 2022 20:07:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231770AbiJQDGK (ORCPT + 99 others); Sun, 16 Oct 2022 23:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbiJQDGI (ORCPT ); Sun, 16 Oct 2022 23:06:08 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2534AD6C; Sun, 16 Oct 2022 20:06:06 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VSGQCyZ_1665975958; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0VSGQCyZ_1665975958) by smtp.aliyun-inc.com; Mon, 17 Oct 2022 11:06:03 +0800 From: Jiapeng Chong To: marcel@holtmann.org Cc: johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset Date: Mon, 17 Oct 2022 11:04:21 +0800 Message-Id: <20221017030421.69108-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Use kzalloc rather than duplicating its implementation, which makes code simple and easy to understand. ./net/bluetooth/hci_conn.c:2038:6-13: WARNING: kzalloc should be used for cp, instead of kmalloc/memset. Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2406 Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong --- net/bluetooth/hci_conn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 5d6ee5075642..495de21d52cd 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2035,13 +2035,12 @@ int hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst, __u8 dst_type, if (hci_dev_test_and_set_flag(hdev, HCI_PA_SYNC)) return -EBUSY; - cp = kmalloc(sizeof(*cp), GFP_KERNEL); + cp = kzalloc(sizeof(*cp), GFP_KERNEL); if (!cp) { hci_dev_clear_flag(hdev, HCI_PA_SYNC); return -ENOMEM; } - memset(cp, 0, sizeof(*cp)); cp->sid = sid; cp->addr_type = dst_type; bacpy(&cp->addr, dst); -- 2.20.1.7.g153144c