Skip to contentSkip to conversation

can: etas_es58x: Fix missing null check on netdev pointer

PATCH In review Colin King 3 participants 4 messages Apr 15, 2021

Subsystems (5)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 can: etas_es58x: Fix missing null check on netdev pointer

From: Colin Ian King <[email protected]>

There is an assignment to *netdev that is can potentially be null but the null check is checking netdev and not *netdev as intended. Fix this by adding in the missing * operator.

Addresses-Coverity: ("Dereference before null check")

Fixes 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
---
 drivers/net/can/usb/etas_es58x/es58x_core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/etas_es58x/es58x_core.h +1 -1
index 5f4e7dc5be35..fcf219e727bf 100644
@@ -625,7 +625,7 @@ static inline int es58x_get_netdev(struct es58x_device *es58x_dev,
 		return -ECHRNG;
 
 	*netdev = es58x_dev->netdev[channel_idx];
-	if (!netdev || !netif_device_present(*netdev))
+	if (!*netdev || !netif_device_present(*netdev))
 		return -ENODEV;
 
 	return 0;
Signature · 1 line
2.30.2
#1 lore raw
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

There is an assignment to *netdev that is can potentially be null but the null check is checking netdev and not *netdev as intended. Fix this by adding in the missing * operator.

Addresses-Coverity: ("Dereference before null check")

Fixes 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")

Looks good. Applied to linux-can-next/testing.

Tnx,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#2 lore raw
Quoted 4 lines · Marc Kleine-Budde
Quoted 3 lines · Colin King

From: Colin Ian King <[email protected]>

There is an assignment to *netdev that is can potentially be null but the

                                           ^^

Typo: that is can -> that can

Quoted 6 lines
Quoted 6 lines

null check is checking netdev and not *netdev as intended. Fix this by adding in the missing * operator.

Addresses-Coverity: ("Dereference before null check")

Fixes 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")

Thanks Colin!

#3 lore raw
Quoted 7 lines · Vincent MAILHOL
Quoted 4 lines · Marc Kleine-Budde
Quoted 3 lines · Colin King

From: Colin Ian King <[email protected]>

There is an assignment to *netdev that is can potentially be null but the

                                           ^^

Typo: that is can -> that can

Fixed.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

null check is checking netdev and not *netdev as intended. Fix this by adding in the missing * operator.

Addresses-Coverity: ("Dereference before null check")

Fixes 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")

Added to the patch.

Tnx,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |