stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Subject: [PATCH 5.10 089/105] Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg
Date: Wed, 27 Jul 2022 18:11:15 +0200	[thread overview]
Message-ID: <20220727161015.668549709@linuxfoundation.org> (raw)
In-Reply-To: <20220727161012.056867467@linuxfoundation.org>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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 <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/bluetooth/sco.c |   34 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 23 deletions(-)

--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -280,27 +280,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)
@@ -727,7 +719,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);
@@ -739,24 +731,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;
 }
 



  parent reply	other threads:[~2022-07-27 16:57 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 16:09 [PATCH 5.10 000/105] 5.10.134-rc1 review Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 001/105] pinctrl: stm32: fix optional IRQ support to gpios Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 002/105] riscv: add as-options for modules with assembly compontents Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 003/105] mlxsw: spectrum_router: Fix IPv4 nexthop gateway indication Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 004/105] lockdown: Fix kexec lockdown bypass with ima policy Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 005/105] io_uring: Use original task for req identity in io_identity_cow() Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 006/105] xen/gntdev: Ignore failure to unmap INVALID_GRANT_HANDLE Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 007/105] block: split bio_kmalloc from bio_alloc_bioset Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 008/105] block: fix bounce_clone_bio for passthrough bios Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 009/105] docs: net: explain struct net_device lifetime Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 010/105] net: make free_netdev() more lenient with unregistering devices Greg Kroah-Hartman
2022-07-28 21:00   ` Pavel Machek
2022-07-29 15:01     ` Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 011/105] net: make sure devices go through netdev_wait_all_refs Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 012/105] net: move net_set_todo inside rollback_registered() Greg Kroah-Hartman
2022-07-27 16:09 ` [PATCH 5.10 013/105] net: inline rollback_registered() Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 014/105] net: move rollback_registered_many() Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 015/105] net: inline rollback_registered_many() Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 016/105] Revert "m68knommu: only set CONFIG_ISA_DMA_API for ColdFire sub-arch" Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 017/105] PCI: hv: Fix multi-MSI to allow more than one MSI vector Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 018/105] PCI: hv: Fix hv_arch_irq_unmask() for multi-MSI Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 019/105] PCI: hv: Reuse existing IRTE allocation in compose_msi_msg() Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 020/105] PCI: hv: Fix interrupt mapping for multi-MSI Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 021/105] serial: mvebu-uart: correctly report configured baudrate value Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 022/105] xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup() Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 023/105] power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 024/105] pinctrl: ralink: Check for null return of devm_kcalloc Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 025/105] perf/core: Fix data race between perf_event_set_output() and perf_mmap_close() Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 026/105] drm/amdgpu/display: add quirk handling for stutter mode Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 027/105] igc: Reinstate IGC_REMOVED logic and implement it properly Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 028/105] ip: Fix data-races around sysctl_ip_no_pmtu_disc Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 029/105] ip: Fix data-races around sysctl_ip_fwd_use_pmtu Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 030/105] ip: Fix data-races around sysctl_ip_fwd_update_priority Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 031/105] ip: Fix data-races around sysctl_ip_nonlocal_bind Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 032/105] ip: Fix a data-race around sysctl_ip_autobind_reuse Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 033/105] ip: Fix a data-race around sysctl_fwmark_reflect Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 034/105] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 035/105] tcp: Fix data-races around sysctl_tcp_mtu_probing Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 036/105] tcp: Fix data-races around sysctl_tcp_base_mss Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 037/105] tcp: Fix data-races around sysctl_tcp_min_snd_mss Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 038/105] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 039/105] tcp: Fix a data-race around sysctl_tcp_probe_threshold Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 040/105] tcp: Fix a data-race around sysctl_tcp_probe_interval Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 041/105] net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 042/105] i2c: cadence: Change large transfer count reset logic to be unconditional Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 043/105] net: stmmac: fix dma queue left shift overflow issue Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 044/105] net/tls: Fix race in TLS device down flow Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 045/105] igmp: Fix data-races around sysctl_igmp_llm_reports Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 046/105] igmp: Fix a data-race around sysctl_igmp_max_memberships Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 047/105] igmp: Fix data-races around sysctl_igmp_max_msf Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 048/105] tcp: Fix data-races around keepalive sysctl knobs Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 049/105] tcp: Fix data-races around sysctl_tcp_syncookies Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 050/105] tcp: Fix data-races around sysctl_tcp_reordering Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 051/105] tcp: Fix data-races around some timeout sysctl knobs Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 052/105] tcp: Fix a data-race around sysctl_tcp_notsent_lowat Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 053/105] tcp: Fix a data-race around sysctl_tcp_tw_reuse Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 054/105] tcp: Fix data-races around sysctl_max_syn_backlog Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 055/105] tcp: Fix data-races around sysctl_tcp_fastopen Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 056/105] tcp: Fix data-races around sysctl_tcp_fastopen_blackhole_timeout Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 057/105] iavf: Fix handling of dummy receive descriptors Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 058/105] i40e: Fix erroneous adapter reinitialization during recovery process Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 059/105] ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 060/105] gpio: pca953x: only use single read/write for No AI mode Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 061/105] gpio: pca953x: use the correct range when do regmap sync Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 062/105] gpio: pca953x: use the correct register address when regcache sync during init Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 063/105] be2net: Fix buffer overflow in be_get_module_eeprom Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 064/105] drm/imx/dcss: Add missing of_node_put() in fail path Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 065/105] ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 066/105] ip: Fix data-races around sysctl_ip_prot_sock Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 067/105] udp: Fix a data-race around sysctl_udp_l3mdev_accept Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 068/105] tcp: Fix data-races around sysctl knobs related to SYN option Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 069/105] tcp: Fix a data-race around sysctl_tcp_early_retrans Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 070/105] tcp: Fix data-races around sysctl_tcp_recovery Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 071/105] tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 072/105] tcp: Fix data-races around sysctl_tcp_slow_start_after_idle Greg Kroah-Hartman
2022-07-27 16:10 ` [PATCH 5.10 073/105] tcp: Fix a data-race around sysctl_tcp_retrans_collapse Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 074/105] tcp: Fix a data-race around sysctl_tcp_stdurg Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 075/105] tcp: Fix a data-race around sysctl_tcp_rfc1337 Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 076/105] tcp: Fix data-races around sysctl_tcp_max_reordering Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 077/105] spi: bcm2835: bcm2835_spi_handle_err(): fix NULL pointer deref for non DMA transfers Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 078/105] KVM: Dont null dereference ops->destroy Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 079/105] mm/mempolicy: fix uninit-value in mpol_rebind_policy() Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 080/105] bpf: Make sure mac_header was set before using it Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 081/105] sched/deadline: Fix BUG_ON condition for deboosted tasks Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 082/105] x86/bugs: Warn when "ibrs" mitigation is selected on Enhanced IBRS parts Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 083/105] dlm: fix pending remove if msg allocation fails Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 084/105] drm/imx/dcss: fix unused but set variable warnings Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 085/105] bitfield.h: Fix "type of reg too small for mask" test Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 086/105] ALSA: memalloc: Align buffer allocations in page size Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 087/105] Bluetooth: Add bt_skb_sendmsg helper Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 088/105] Bluetooth: Add bt_skb_sendmmsg helper Greg Kroah-Hartman
2022-07-27 16:11 ` Greg Kroah-Hartman [this message]
2022-07-27 16:11 ` [PATCH 5.10 090/105] Bluetooth: RFCOMM: Replace use of memcpy_from_msg with bt_skb_sendmmsg Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 091/105] Bluetooth: Fix passing NULL to PTR_ERR Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 092/105] Bluetooth: SCO: Fix sco_send_frame returning skb->len Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 093/105] Bluetooth: Fix bt_skb_sendmmsg not allocating partial chunks Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 094/105] x86/amd: Use IBPB for firmware calls Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 095/105] x86/alternative: Report missing return thunk details Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 096/105] watchqueue: make sure to serialize wqueue->defunct properly Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 097/105] tty: drivers/tty/, stop using tty_schedule_flip() Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 098/105] tty: the rest, " Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 099/105] tty: drop tty_schedule_flip() Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 100/105] tty: extract tty_flip_buffer_commit() from tty_flip_buffer_push() Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 101/105] tty: use new tty_insert_flip_string_and_push_buffer() in pty_write() Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 102/105] net: usb: ax88179_178a needs FLAG_SEND_ZLP Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 103/105] watch-queue: remove spurious double semicolon Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 104/105] block: fix memory leak of bvec Greg Kroah-Hartman
2022-07-27 16:11 ` [PATCH 5.10 105/105] block-crypto-fallback: use a bio_set for splitting bios Greg Kroah-Hartman
2022-07-28  0:02 ` [PATCH 5.10 000/105] 5.10.134-rc1 review Florian Fainelli
2022-07-28  8:20 ` Naresh Kamboju
2022-07-28  9:44 ` Pavel Machek
2022-07-28 13:20 ` Guenter Roeck
2022-07-28 14:22   ` Guenter Roeck
2022-07-28 14:40     ` Greg Kroah-Hartman
2022-07-28 14:32 ` Jon Hunter
2022-07-28 14:41 ` Shuah Khan
2022-07-28 14:44 ` Sudip Mukherjee (Codethink)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220727161015.668549709@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=harshit.m.mogalapalli@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).