* [PATCH] net: thunderx: avoid dereferencing xcv when NULL
@ 2017-01-30 14:06 Vincent Stehlé
2017-01-31 18:09 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Stehlé @ 2017-01-30 14:06 UTC (permalink / raw)
To: linux-arm-kernel, netdev; +Cc: Sunil Goutham, linux-kernel, Vincent Stehlé
This fixes the following smatch and coccinelle warnings:
drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch]
drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle]
Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support")
Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Sunil Goutham <sgoutham@cavium.com>
---
drivers/net/ethernet/cavium/thunder/thunder_xcv.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_xcv.c b/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
index 67befedef709..578c7f8f11bf 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
@@ -116,8 +116,7 @@ void xcv_setup_link(bool link_up, int link_speed)
int speed = 2;
if (!xcv) {
- dev_err(&xcv->pdev->dev,
- "XCV init not done, probe may have failed\n");
+ pr_err("XCV init not done, probe may have failed\n");
return;
}
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net: thunderx: avoid dereferencing xcv when NULL
2017-01-30 14:06 [PATCH] net: thunderx: avoid dereferencing xcv when NULL Vincent Stehlé
@ 2017-01-31 18:09 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-01-31 18:09 UTC (permalink / raw)
To: vincent.stehle; +Cc: linux-arm-kernel, netdev, linux-kernel, sgoutham
From: Vincent Stehlé <vincent.stehle@laposte.net>
Date: Mon, 30 Jan 2017 15:06:43 +0100
> This fixes the following smatch and coccinelle warnings:
>
> drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch]
> drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle]
>
> Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support")
> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> Cc: Sunil Goutham <sgoutham@cavium.com>
I've applied this, but wow this is some code that needs fixing on a more
fundamental level.
Having a global pointer for a device private and assuming only one instance
of a PCI device ID will ever be probe in a system is really wrong.
This is true even in all known machines or configurations this might
be true.
It leads to exactly the kinds of problems shown here.
Objects should be probed by instance, and if operations need to
be performed on it, a pointer to the software state for that object
instance should be passed around. Rather than having an implicit
single object.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-31 18:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-30 14:06 [PATCH] net: thunderx: avoid dereferencing xcv when NULL Vincent Stehlé
2017-01-31 18:09 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox