Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp482964imn; Wed, 27 Jul 2022 11:27:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tkuwndZ+pOC8Z6ZkfMM9MhiibmzsG714dGaWwBqEx/kbqJKZx4AR7/Kr5uygmR2ZtU8kTT X-Received: by 2002:a63:4a41:0:b0:41a:a605:f07b with SMTP id j1-20020a634a41000000b0041aa605f07bmr20167273pgl.279.1658946439882; Wed, 27 Jul 2022 11:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946439; cv=none; d=google.com; s=arc-20160816; b=OwumMSvl9PF+6PxDPqvCP6IRg4bd1MmYgDnpXrG+0ownhbUfEmgCKDrdHRP832jRoP /5SFyXQiS0LbpHOZsaz+mCMcKz+X+LaalthmZ8l7tFfQC/CVlaV6MCqxli2iPquK9kb/ 0S6btYchHuyvbyvfB870k9WcKK9+TJcK88EIB8Qpl9yQxZ3VK1iUhSQnkO5ReyUGmFQY Xhie/DGLtj4dXKlp/lymEiJ3tXG0wzgRnQyieXXsFW6jVx0cr9bhp1lz0Pq/5rJ+S6oG e6BX8dRIvaP4N46pzNglV23o1G7fUJ+Gs557fY/MD/SbIizFJMCzydOXjKYJH1jjJYAg 0A6w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lmwY7yuD/nnNvkShizYzCf97W2k6SJCbCnun+Lhk4I8=; b=vksuFn7n6iOlcw7AlTNQ5kohLjVsYVS/NvHhzKpa0gEd0R9m0G/SsyzP7zQaBddQjO 25pmg6j+oyhY8AyE1OMGVGO/NCHXxC/Zg7p6hS/uWS7xnF/gktRkfXlgjRN8jIodR+xc J9HNbdlCK2ZIYH9CwSa9LmzLZewWR+9YS0wgIvP9UTKkEac/yfpddVrDWoUnbh7V5si6 Ja8NMr7ouFnIPvEjgZ02ASFncRXc+syTL3hRrsPPJEaYhlQv+yRqYa3WKwVJDDiJyxe+ abCgBz5v9xUo1nsdOrkofmupYWMa0gIvjFSTpBxuLxIv4gJDXFt1dFBpoKLkVQZUY41U Y8Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tRQQp57W; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb3-20020a17090ae7c300b001f30b3b6336si3188663pjb.147.2022.07.27.11.26.57; Wed, 27 Jul 2022 11:27:19 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tRQQp57W; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238705AbiG0Qg1 (ORCPT + 99 others); Wed, 27 Jul 2022 12:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239079AbiG0Qew (ORCPT ); Wed, 27 Jul 2022 12:34:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A947F4F659; Wed, 27 Jul 2022 09:27:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 77B9EB821BF; Wed, 27 Jul 2022 16:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D23C7C433D6; Wed, 27 Jul 2022 16:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939201; bh=tS+ar2byvGXQkV54OvZ4Jwy6/JT/BUmN8BRsenhz6fA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tRQQp57W4DJp6oDKK+2WINwBFizrCB9DuEcxuwk1HHnm+ijMp6SN/X3iaMncEGers Um5LrRqFFwHeEkLLqjOw6VLePDW59Gq6yT9v7tX6zub78V/pa3aP0pCKObQxo3zOnZ HGnb9Kjj9a0kKk9aIxRiB+NHtsYo5RjdRxVPu4cc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Harshit Mogalapalli Subject: [PATCH 4.19 47/62] Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg Date: Wed, 27 Jul 2022 18:10:56 +0200 Message-Id: <20220727161005.976577904@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Luiz Augusto von Dentz commit 0771cbb3b97d3c1d68eecd7f00055f599954c34e upstream. This makes use of bt_skb_sendmsg instead of allocating a different buffer to be used with memcpy_from_msg which cause one extra copy. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Cc: Harshit Mogalapalli Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/sco.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -279,27 +279,19 @@ static int sco_connect(struct hci_dev *h return err; } -static int sco_send_frame(struct sock *sk, void *buf, int len, - unsigned int msg_flags) +static int sco_send_frame(struct sock *sk, struct sk_buff *skb) { struct sco_conn *conn = sco_pi(sk)->conn; - struct sk_buff *skb; - int err; /* Check outgoing MTU */ - if (len > conn->mtu) + if (skb->len > conn->mtu) return -EINVAL; - BT_DBG("sk %p len %d", sk, len); - - skb = bt_skb_send_alloc(sk, len, msg_flags & MSG_DONTWAIT, &err); - if (!skb) - return err; + BT_DBG("sk %p len %d", sk, skb->len); - memcpy(skb_put(skb, len), buf, len); hci_send_sco(conn->hcon, skb); - return len; + return skb->len; } static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) @@ -715,7 +707,7 @@ static int sco_sock_sendmsg(struct socke size_t len) { struct sock *sk = sock->sk; - void *buf; + struct sk_buff *skb; int err; BT_DBG("sock %p, sk %p", sock, sk); @@ -727,24 +719,20 @@ static int sco_sock_sendmsg(struct socke if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; - buf = kmalloc(len, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - if (memcpy_from_msg(buf, msg, len)) { - kfree(buf); - return -EFAULT; - } + skb = bt_skb_sendmsg(sk, msg, len, len, 0, 0); + if (IS_ERR_OR_NULL(skb)) + return PTR_ERR(skb); lock_sock(sk); if (sk->sk_state == BT_CONNECTED) - err = sco_send_frame(sk, buf, len, msg->msg_flags); + err = sco_send_frame(sk, skb); else err = -ENOTCONN; release_sock(sk); - kfree(buf); + if (err) + kfree_skb(skb); return err; }