mirror of https://lore.kernel.org/lkml/
 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.14 16/23] can: bcm: check the result of can_send() in bcm_can_tx()
Date: Sun,  9 Oct 2022 18:25:46 -0400	[thread overview]
Message-ID: <20221009222557.1219968-16-sashal@kernel.org> (raw)
In-Reply-To: <20221009222557.1219968-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 b3f3b02ffd42..89b955ef75d1 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -286,6 +286,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)
@@ -310,11 +311,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 23:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-09 22:25 [PATCH AUTOSEL 4.14 01/23] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 02/23] openvswitch: Fix double reporting of drops in dropwatch Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 03/23] openvswitch: Fix overreporting " Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 04/23] tcp: annotate data-race around tcp_md5sig_pool_populated Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 05/23] wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 06/23] xfrm: Update ipcomp_scratches with NULL when freed Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 07/23] net: xscale: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 08/23] net: lantiq_etop: " Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 09/23] net: ftmac100: fix endianness-related issues from 'sparse' Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 10/23] wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit() Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 11/23] Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 12/23] net: davicom: Fix return type of dm9000_start_xmit Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 13/23] net: ethernet: ti: davinci_emac: Fix return type of emac_dev_xmit Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 14/23] net: korina: Fix return type of korina_send_packet Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 15/23] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Sasha Levin
2022-10-09 22:25 ` Sasha Levin [this message]
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 17/23] wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 18/23] wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 19/23] wifi: rt2x00: set SoC wmac clock register Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 20/23] wifi: rt2x00: correctly set BBP register 86 for MT7620 Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 21/23] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 22/23] Bluetooth: L2CAP: Fix user-after-free Sasha Levin
2022-10-09 22:25 ` [PATCH AUTOSEL 4.14 23/23] 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=20221009222557.1219968-16-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®