From: David Miller <davem@davemloft.net>
To: nsekhar@ti.com
Cc: grygorii.strashko@ti.com, linux-omap@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: ti: cpsw: fix race condition during open()
Date: Tue, 04 Apr 2017 10:33:48 -0700 (PDT) [thread overview]
Message-ID: <20170404.103348.2265460653101200539.davem@davemloft.net> (raw)
In-Reply-To: <509439ff3e756ea1dade2738e305f08fc7920650.1491220439.git.nsekhar@ti.com>
From: Sekhar Nori <nsekhar@ti.com>
Date: Mon, 3 Apr 2017 17:34:28 +0530
> TI's cpsw driver handles both OF and non-OF case for phy
> connect. Unfortunately of_phy_connect() returns NULL on
> error while phy_connect() returns ERR_PTR().
>
> To handle this, cpsw_slave_open() overrides the return value
> from phy_connect() to make it NULL or error.
>
> This leaves a small window, where cpsw_adjust_link() may be
> invoked for a slave while slave->phy pointer is temporarily
> set to -ENODEV (or some other error) before it is finally set
> to NULL.
>
> _cpsw_adjust_link() only handles the NULL case, and an oops
> results when ERR_PTR() is seen by it.
>
> Note that cpsw_adjust_link() checks PHY status for each
> slave whenever it is invoked. It can so happen that even
> though phy_connect() for a given slave returns error,
> _cpsw_adjust_link() is still called for that slave because
> the link status of another slave changed.
>
> Fix this by using a temporary pointer to store return value
> of {of_}phy_connect() and do a one-time write to slave->phy.
>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reported-by: Yan Liu <yan-liu@ti.com>
> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Applied, thank you.
prev parent reply other threads:[~2017-04-04 17:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-03 12:04 [PATCH] net: ethernet: ti: cpsw: fix race condition during open() Sekhar Nori
2017-04-04 17:33 ` 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=20170404.103348.2265460653101200539.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=grygorii.strashko@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nsekhar@ti.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).