Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14659516rwd; Sun, 25 Jun 2023 01:47:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7C7WeJF+m8w/5hB1UN6AVD3rUbk2JaBUun+krzOt52wFOkjqEUInJWuWJxVQgwUuvTJ/vC X-Received: by 2002:a05:6870:c7b5:b0:1b0:1d1d:560b with SMTP id dy53-20020a056870c7b500b001b01d1d560bmr2973923oab.12.1687682873120; Sun, 25 Jun 2023 01:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687682873; cv=none; d=google.com; s=arc-20160816; b=ZTVep+YDiuS7N0eE2gWUftDfjWurBSKFREoV1CfPHPuElwwwNUPjEJ4/FKxQdNRxqu IToqCCCj3vAGJrT9H0qqy0/w2FNTWgttQzvqYXXORIaLjJY8JTlVpmjLf+sW9ZAHHKsq baEtTj8IWabgZCR/J2PhVznKLOSxeo3Lm5SB44zUjinzlUcdSjuI0RDhDz8+LYu/09tU z+CAm32dIT97WQkXF8do+dHMBqe375MvW8ka8Kg9p5vfOlx4yoSvQoxzEvj0cmbLEdBa rTpEFr417VXaBHE2v+GgreYZ2tir0K8TWHIhvjINerEPdpNvq7fh/6xyw3KFtUT4aXN7 0RMQ== 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=tTte8cBpaGZ/90CAo79YHxAwV2mc7fo8ZJmh2dPn8o4=; fh=FJixqOFu4CZJoSHTBxsa8q7xVoUKTNWYwEBYWABE30w=; b=VvC2ItQkB0+XGnDARr9KJt42kLfiQZETpR95kLxuSn5u7YecHQ+RCKDBk9+/Zg1Cwv GHTkbe0TkgcYLr2yfBStKH/QeEyKv7TH/juDqxuTvbQjjPF5flGA3468dWnNA1cT9Vmr adjFDr3XDV+Nh3AfhLSC8ToNTSTZOyb18QjUErUXaXyg8EbBSTWA8AlERbeuge0rSixn Oh+J3LdHBm8K53u/72IT87/PeXJ54GoIFF6yIkENyNBeTpVG/uQ1wwNrzAbCnhE+B81L nuvE4fmesP9lAidKat6df9CGH5VZcy5f2dW1M7dJF12KqabHEX+D5KM42Jsetme2Oehg qRow== 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 i4-20020a63e444000000b005348464b81fsi2916952pgk.371.2023.06.25.01.47.30; Sun, 25 Jun 2023 01:47:53 -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 S230254AbjFYIp3 (ORCPT + 99 others); Sun, 25 Jun 2023 04:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbjFYIp2 (ORCPT ); Sun, 25 Jun 2023 04:45:28 -0400 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B3B1AE; Sun, 25 Jun 2023 01:45:26 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Vlro46n_1687682714; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0Vlro46n_1687682714) by smtp.aliyun-inc.com; Sun, 25 Jun 2023 16:45:24 +0800 From: Jiapeng Chong To: marcel@holtmann.org Cc: johan.hedberg@gmail.com, luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] Bluetooth: hci_conn: Use kmemdup() to replace kzalloc + memcpy Date: Sun, 25 Jun 2023 16:45:13 +0800 Message-Id: <20230625084513.6319-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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,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 kmemdup rather than duplicating its implementation. ./net/bluetooth/hci_conn.c:1880:7-14: WARNING opportunity for kmemdup. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5597 Signed-off-by: Jiapeng Chong --- net/bluetooth/hci_conn.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 62a7ccfdfe63..47e7aa4d63a9 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1877,12 +1877,10 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos) if (qos->ucast.cis == BT_ISO_QOS_CIS_UNSET || !data.pdu.cp.num_cis) return false; - pdu = kzalloc(sizeof(*pdu), GFP_KERNEL); + pdu = kmemdup(&data.pdu, sizeof(*pdu), GFP_KERNEL); if (!pdu) return false; - memcpy(pdu, &data.pdu, sizeof(*pdu)); - if (hci_cmd_sync_queue(hdev, set_cig_params_sync, pdu, set_cig_params_complete) < 0) { kfree(pdu); -- 2.20.1.7.g153144c