Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3983078rwi; Sun, 16 Oct 2022 22:57:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58td6/8UNBSpLYyfomOazfDfA7RHtgT3aEhC3BNJaAntZ+hFDAY1J782eyY6+TVW/sGika X-Received: by 2002:a17:902:7481:b0:180:58d7:24e0 with SMTP id h1-20020a170902748100b0018058d724e0mr10297675pll.49.1665986247276; Sun, 16 Oct 2022 22:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665986247; cv=none; d=google.com; s=arc-20160816; b=bFx+o+7bL5vytX5gmGsthf+nRi1YILQaxL79pdZG0RHnSkCNiAvikTl+XPslkOHx3u RsjYPNeWzf9japtwAhsKYqMtxoICpb0brI2cp/ctG4N0caftIOxKviFa3Oy25Ymt5Zhr 6l/Me8aJUKvXXZdNMKdwMdfjKUrMx4GK8z/ssLe5YkYq34CO86xngCMEWMLCLDd03V/T FFA9HT7gqm6NH/QO0L8YVfZc4BX2xeLukK+n4Amidv6hbQ3bnsZs3e6c7yjFSnMM7RHA ICp9nw/IMRqb7OomfOTOyjadsUSQdu1rZkNDNC97O9sN005up2i2zAWYQvNJri3slvXI M2+A== 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=cWDdAmtwSI6G8+Xx4e2PWpK4ZdugOqsvRU3OSMhUkMpUujDWV8fIW5VINazEemj7R7 +CZEIsNLPt1GR+qZWMu877rr6oNq18dBLplhsXKlzdKW/BweTD3UTzwrXaKQhtwZvpwF A7ZFCjgCBj8ujuF3jXneqY+rh+wS/k3or7hyHZjlvHCKO/ijslgOTNr/veLVT5AKz73X Q7hQD9Vx72lL/eoTuiSbQKCFSCKEDWLlJFbwydg+u4gifVL3yawN/sJjQf8GC4op66nd Mn17bNQmt2Ih0SU/55l4LfVLelv0hEVWfAon9ycz/Eeu3EHqmT2SJhLWUcX2KgRgcXX5 is3Q== 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 l2-20020a056a0016c200b005634a0ecb53si10396569pfc.265.2022.10.16.22.57.01; Sun, 16 Oct 2022 22:57:27 -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 S229697AbiJQFrg (ORCPT + 99 others); Mon, 17 Oct 2022 01:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiJQFrg (ORCPT ); Mon, 17 Oct 2022 01:47:36 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 192E94E199; Sun, 16 Oct 2022 22:47:33 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VSIKI1E_1665985636; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0VSIKI1E_1665985636) by smtp.aliyun-inc.com; Mon, 17 Oct 2022 13:47:30 +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] Bluetooth: Use kzalloc instead of kmalloc/memset Date: Mon, 17 Oct 2022 13:47:13 +0800 Message-Id: <20221017054713.7507-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