From patchwork Mon Oct 17 03:04:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiapeng Chong X-Patchwork-Id: 3192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1243950wrs; Sun, 16 Oct 2022 20:06:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6RkdJcrnmfkRv7/vq9T3ccwF4YKgQv2rtyePVKM3khwJvF2sATAN7fetWVH9I80sGDv4q2 X-Received: by 2002:a65:6e9a:0:b0:44c:2476:12e0 with SMTP id bm26-20020a656e9a000000b0044c247612e0mr9000700pgb.159.1665976013065; Sun, 16 Oct 2022 20:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665976013; cv=none; d=google.com; s=arc-20160816; b=xn3k6msfDoLb7tICZwxiiZYWG1L/++eAndsbkhxZ5DJ3dBEdVXeRho8/u4O4jDfe5B V2mCNOnmQR8g1y/xagogp1YdgR1WEGIDoT7GQ1cOFo29DbzMvua0SPGuc/CCVOtQ2Ib2 VwfSiz3YQsD+WQwgla658PwJ+JHG+HpiDC0zPywFwNp3qO0j/IZLl94nn7kpGmbKr6UA 3OpnEwwUn68OgfE2cOPXGOdZiZYTIV/WSX+FogbZI1q5r8sPlxLVuD+2sPblB3jNRpq0 CIhht1K4Uu9pkVcIGNKWa+fM4k6JTeiNBiJzeNke3qeKUon8iEfpWD1HL7wu77jfsam6 qy2g== 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=OilEqkurm8CTfIvj1CelSomILeDT37psxZQqmApAmYF5xFUsQXzXGnnBHPbd9o051M kPRW2NebfLS0V5fik1FTaYZmernX1b5Nkp7XXHf7TMt55oubbRaergpZFW0Tha0MvOyh 0zP810DK0POEpHY8Ow6h0fhnnTZTlEXaAnw+0nXYz+tDmZmD9JYNr6BCBLEcr7SpF2hV 0NOEsSi3AChVPTKeFKXT0iEYLTm+WHVddzlHMLxfF6LVY2er7dqyJyaBD5NL+S1+KS1K inKUD1Yzfs50wJHf4k/XzbHoqzZ2hfJPYLamXVpnh1kroY/YYj7MR/anOkAoDAhxyebx UHwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a63ad44000000b0043cb5d08908si10646518pgo.138.2022.10.16.20.06.40; Sun, 16 Oct 2022 20:06:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S231776AbiJQDGN (ORCPT + 99 others); Sun, 16 Oct 2022 23:06:13 -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 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746902463599016847?= X-GMAIL-MSGID: =?utf-8?q?1746902463599016847?= 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);