diff mbox series

[next] can: etas_es58x: Fix missing null check on netdev pointer

Message ID 20210415084723.1807935-1-colin.king@canonical.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [next] can: etas_es58x: Fix missing null check on netdev pointer | expand

Checks

Context Check Description
netdev/tree_selection success Series ignored based on subject

Commit Message

Colin King April 15, 2021, 8:47 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/can/usb/etas_es58x/es58x_core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc Kleine-Budde April 15, 2021, 9:04 a.m. UTC | #1
On 15.04.2021 09:47:23, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

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

Tnx,
Marc
Vincent Mailhol April 15, 2021, 11:42 a.m. UTC | #2
On Thu. 15 Apr 2021 at 18:04, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> On 15.04.2021 09:47:23, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > There is an assignment to *netdev that is can potentially be null but the
                                           ^^
Typo: that is can -> that can

> > 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")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Thanks Colin!
Marc Kleine-Budde April 15, 2021, 11:47 a.m. UTC | #3
On 15.04.2021 20:42:36, Vincent MAILHOL wrote:
> On Thu. 15 Apr 2021 at 18:04, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > On 15.04.2021 09:47:23, Colin King wrote:
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > There is an assignment to *netdev that is can potentially be null but the
>                                            ^^
> Typo: that is can -> that can

Fixed.

> > > 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")
> > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Added to the patch.

Tnx,
Marc
diff mbox series

Patch

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index 5f4e7dc5be35..fcf219e727bf 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -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;