From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Robert Hancock <hancock@sedsystems.ca>,
netdev@vger.kernel.org, woojung.huh@microchip.com,
UNGLinuxDriver@microchip.com
Subject: Re: net-next: KSZ switch driver oops in ksz_mib_read_work
Date: Wed, 12 Jun 2019 16:09:05 +0200 [thread overview]
Message-ID: <20190612140905.GB18923@lunn.ch> (raw)
In-Reply-To: <3f8ee5e5-9996-dd74-807a-a4b24cd9ee4c@gmail.com>
On Tue, Jun 11, 2019 at 04:27:47PM -0700, Florian Fainelli wrote:
> On 6/11/19 10:57 AM, Robert Hancock wrote:
> > We are using an embedded platform with a KSZ9897 switch. I am getting
> > the oops below in ksz_mib_read_work when testing with net-next branch.
> > After adding in some debug output, the problem is in this code:
> >
> > for (i = 0; i < dev->mib_port_cnt; i++) {
> > p = &dev->ports[i];
> > mib = &p->mib;
> > mutex_lock(&mib->cnt_mutex);
> >
> > /* Only read MIB counters when the port is told to do.
> > * If not, read only dropped counters when link is not up.
> > */
> > if (!p->read) {
> > const struct dsa_port *dp = dsa_to_port(dev->ds, i);
> >
> > if (!netif_carrier_ok(dp->slave))
> > mib->cnt_ptr = dev->reg_mib_cnt;
> > }
> >
> > The oops is happening on port index 3 (i.e. 4th port) which is not
> > connected on our platform and so has no entry in the device tree. For
> > that port, dp->slave is NULL and so netif_carrier_ok explodes.
> >
> > If I change the code to skip the port entirely in the loop if dp->slave
> > is NULL it seems to fix the crash, but I'm not that familiar with this
> > code. Can someone confirm whether that is the proper fix?
>
> Yes, the following should do it, if you confirm that is the case, I can
> send that later with your Tested-by.
>
> diff --git a/drivers/net/dsa/microchip/ksz_common.c
> b/drivers/net/dsa/microchip/ksz_common.c
> index 39dace8e3512..5470b28332cf 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -93,6 +93,9 @@ static void ksz_mib_read_work(struct work_struct *work)
> if (!p->read) {
> const struct dsa_port *dp = dsa_to_port(dev->ds, i);
>
> + if (dsa_is_unused_port(dp))
> + continue;
> +
> if (!netif_carrier_ok(dp->slave))
> mib->cnt_ptr = dev->reg_mib_cnt;
> }
>
Hi Florian
There is a mutex held within the loop. So a continue is not going to
work here.
Andrew
prev parent reply other threads:[~2019-06-12 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-11 17:57 net-next: KSZ switch driver oops in ksz_mib_read_work Robert Hancock
2019-06-11 23:27 ` Florian Fainelli
2019-06-12 14:09 ` Andrew Lunn [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=20190612140905.GB18923@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=f.fainelli@gmail.com \
--cc=hancock@sedsystems.ca \
--cc=netdev@vger.kernel.org \
--cc=woojung.huh@microchip.com \
/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;
as well as URLs for NNTP newsgroup(s).