All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ziyang Xuan <william.xuanziyang@huawei.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Sasha Levin <sashal@kernel.org>,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-can@vger.kernel.org,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 17/25] can: bcm: check the result of can_send() in bcm_can_tx()
Date: Sun,  9 Oct 2022 18:24:22 -0400	[thread overview]
Message-ID: <20221009222436.1219411-17-sashal@kernel.org> (raw)
In-Reply-To: <20221009222436.1219411-1-sashal@kernel.org>

From: Ziyang Xuan <william.xuanziyang@huawei.com>

[ Upstream commit 3fd7bfd28cfd68ae80a2fe92ea1615722cc2ee6e ]

If can_send() fail, it should not update frames_abs counter
in bcm_can_tx(). Add the result check for can_send() in bcm_can_tx().

Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Suggested-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Link: https://lore.kernel.org/all/9851878e74d6d37aee2f1ee76d68361a46f89458.1663206163.git.william.xuanziyang@huawei.com
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/can/bcm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/can/bcm.c b/net/can/bcm.c
index 3c825b158fb5..74e555a22de7 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -273,6 +273,7 @@ static void bcm_can_tx(struct bcm_op *op)
 	struct sk_buff *skb;
 	struct net_device *dev;
 	struct canfd_frame *cf = op->frames + op->cfsiz * op->currframe;
+	int err;
 
 	/* no target device? => exit */
 	if (!op->ifindex)
@@ -297,11 +298,11 @@ static void bcm_can_tx(struct bcm_op *op)
 	/* send with loopback */
 	skb->dev = dev;
 	can_skb_set_owner(skb, op->sk);
-	can_send(skb, 1);
+	err = can_send(skb, 1);
+	if (!err)
+		op->frames_abs++;
 
-	/* update statistics */
 	op->currframe++;
-	op->frames_abs++;
 
 	/* reached last frame? */
 	if (op->currframe >= op->nframes)
-- 
2.35.1


  parent reply	other threads:[~2022-10-09 22:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-09 22:24 [PATCH AUTOSEL 4.19 01/25] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 02/25] openvswitch: Fix double reporting of drops in dropwatch Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 03/25] openvswitch: Fix overreporting " Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 04/25] tcp: annotate data-race around tcp_md5sig_pool_populated Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 05/25] wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 06/25] xfrm: Update ipcomp_scratches with NULL when freed Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 07/25] net: xscale: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 08/25] net: lantiq_etop: " Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 09/25] net: ftmac100: fix endianness-related issues from 'sparse' Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 10/25] wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit() Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 11/25] Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 12/25] net: davicom: Fix return type of dm9000_start_xmit Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 13/25] net: ethernet: ti: davinci_emac: Fix return type of emac_dev_xmit Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 14/25] net: korina: Fix return type of korina_send_packet Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 15/25] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 16/25] wifi: ath10k: reset pointer after memory free to avoid potential use-after-free Sasha Levin
2022-10-09 22:24   ` Sasha Levin
2022-10-18  9:53   ` Pavel Machek
2022-10-18  9:53     ` Pavel Machek
2022-10-18 11:10     ` Greg KH
2022-10-18 11:10       ` Greg KH
2022-10-09 22:24 ` Sasha Levin [this message]
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 18/25] wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 19/25] wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 20/25] wifi: rt2x00: set SoC wmac clock register Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 21/25] wifi: rt2x00: correctly set BBP register 86 for MT7620 Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 22/25] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 23/25] Bluetooth: L2CAP: Fix user-after-free Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 24/25] libbpf: Fix overrun in netlink attribute iteration Sasha Levin
2022-10-09 22:24 ` [PATCH AUTOSEL 4.19 25/25] r8152: Rate limit overflow messages Sasha Levin

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=20221009222436.1219411-17-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=socketcan@hartkopp.net \
    --cc=stable@vger.kernel.org \
    --cc=william.xuanziyang@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.