From: David Miller <davem@davemloft.net>
To: vincent.stehle@laposte.net
Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, sgoutham@cavium.com
Subject: Re: [PATCH] net: thunderx: avoid dereferencing xcv when NULL
Date: Tue, 31 Jan 2017 13:09:44 -0500 (EST) [thread overview]
Message-ID: <20170131.130944.1449047914150613032.davem@davemloft.net> (raw)
In-Reply-To: <20170130140643.24182-1-vincent.stehle@laposte.net>
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.
prev parent reply other threads:[~2017-01-31 18:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 14:06 [PATCH] net: thunderx: avoid dereferencing xcv when NULL Vincent Stehlé
2017-01-31 18:09 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170131.130944.1449047914150613032.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sgoutham@cavium.com \
--cc=vincent.stehle@laposte.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox