[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210415085535.1808272-1-colin.king@canonical.com>
Date: Thu, 15 Apr 2021 09:55:35 +0100
From: Colin King <colin.king@...onical.com>
To: Wolfgang Grandegger <wg@...ndegger.com>,
Marc Kleine-Budde <mkl@...gutronix.de>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
Arunachalam Santhanam <arunachalam.santhanam@...bosch.com>,
linux-can@...r.kernel.org, netdev@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH][next] can: etas_es58x: Fix potential null pointer dereference on pointer cf
From: Colin Ian King <colin.king@...onical.com>
The pointer cf is being null checked earlier in the code, however the
update of the rx_bytes statistics is dereferencing cf without null
checking cf. Fix this by moving the statement into the following code
block that has a null cf check.
Addresses-Coverity: ("Dereference after null check")
Fixes: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
Signed-off-by: Colin Ian King <colin.king@...onical.com>
---
drivers/net/can/usb/etas_es58x/es58x_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index 7222b3b6ca46..5198e1d6b6ad 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -856,9 +856,10 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error,
* consistency.
*/
netdev->stats.rx_packets++;
- netdev->stats.rx_bytes += cf->can_dlc;
if (cf) {
+ netdev->stats.rx_bytes += cf->can_dlc;
+
if (cf->data[1])
cf->can_id |= CAN_ERR_CRTL;
if (cf->data[2] || cf->data[3]) {
--
2.30.2
Powered by blists - more mailing lists