lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241116180301.3935879-3-dario.binacchi@amarulasolutions.com>
Date: Sat, 16 Nov 2024 19:02:31 +0100
From: Dario Binacchi <dario.binacchi@...rulasolutions.com>
To: linux-kernel@...r.kernel.org
Cc: linux-amarula@...rulasolutions.com,
	Dario Binacchi <dario.binacchi@...rulasolutions.com>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Marc Kleine-Budde <mkl@...gutronix.de>,
	Marek Vasut <marex@...x.de>,
	Paolo Abeni <pabeni@...hat.com>,
	Uwe Kleine-König <u.kleine-koenig@...libre.com>,
	Vincent Mailhol <mailhol.vincent@...adoo.fr>,
	linux-can@...r.kernel.org,
	netdev@...r.kernel.org
Subject: [PATCH 2/7] can: ifi_canfd: fix {rx,tx}_errors statistics

The ifi_canfd_handle_lec_err() function was incorrectly incrementing only
the receive error counter, even in cases of bit or acknowledgment errors
that occur during transmission. The patch fixes the issue by incrementing
the appropriate counter based on the type of error.

Fixes: 5bbd655a8bd0 ("can: ifi: Add more detailed error reporting")
Signed-off-by: Dario Binacchi <dario.binacchi@...rulasolutions.com>
---

 drivers/net/can/ifi_canfd/ifi_canfd.c | 29 +++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c
index d32b10900d2f..3944821303fc 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -390,7 +390,6 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev)
 		return 0;
 
 	priv->can.can_stats.bus_error++;
-	stats->rx_errors++;
 
 	/* Propagate the error condition to the CAN stack. */
 	skb = alloc_can_err_skb(ndev, &cf);
@@ -400,26 +399,40 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev)
 	/* Read the error counter register and check for new errors. */
 	cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
 
-	if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) {
 		cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
+		stats->rx_errors++;
+	}
 
-	if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) {
 		cf->data[3] = CAN_ERR_PROT_LOC_ACK;
+		stats->tx_errors++;
+	}
 
-	if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) {
 		cf->data[2] |= CAN_ERR_PROT_BIT0;
+		stats->tx_errors++;
+	}
 
-	if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) {
 		cf->data[2] |= CAN_ERR_PROT_BIT1;
+		stats->tx_errors++;
+	}
 
-	if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) {
 		cf->data[2] |= CAN_ERR_PROT_STUFF;
+		stats->rx_errors++;
+	}
 
-	if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) {
 		cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
+		stats->rx_errors++;
+	}
 
-	if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST)
+	if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) {
 		cf->data[2] |= CAN_ERR_PROT_FORM;
+		stats->rx_errors++;
+	}
 
 	/* Reset the error counter, ack the IRQ and re-enable the counter. */
 	writel(IFI_CANFD_ERROR_CTR_ER_RESET, priv->base + IFI_CANFD_ERROR_CTR);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ