Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Colin Ian King <colin.king@canonical.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: net: phy: continue searching for C45 MMDs even if first returned ffff:ffff
Date: Mon, 20 Jul 2020 19:31:21 +0300	[thread overview]
Message-ID: <20200720163121.sihkkncthvwnfqd7@skbuf> (raw)
In-Reply-To: <4131864f-9e3e-9814-5f4d-16c93648bce2@canonical.com>

On Mon, Jul 20, 2020 at 05:21:13PM +0100, Colin Ian King wrote:
> Hi,
> 
> Static analysis by Coverity has found a potential issue with the
> following commit in /drivers/net/phy/phy_device.c:
> 
> commit bba238ed037c60242332dd1e4c5778af9eba4d9b
> Author: Vladimir Oltean <vladimir.oltean@nxp.com>
> Date:   Sun Jul 12 19:48:15 2020 +0300
> 
>     net: phy: continue searching for C45 MMDs even if first returned
> ffff:ffff
> 
> The analysis is as follows:
> 
> 735         * for 802.3 c45 complied PHYs, so don't probe it at first.
> 736         */
> 
> dead_error_condition: The condition (devs_in_pkg & 0x1fffffffU) ==
> 0x1fffffffU cannot be true.
> 
> 737        for (i = 1; i < MDIO_MMD_NUM && devs_in_pkg == 0 &&
> 
> const: At condition (devs_in_pkg & 0x1fffffffU) == 0x1fffffffU, the
> value of devs_in_pkg must be equal to 0.
> 
> 738             (devs_in_pkg & 0x1fffffff) == 0x1fffffff; i++) {
> 
> Logically dead code (DEADCODE)dead_error_line: Execution cannot reach
> this statement: if (i == 30 || i == 31) {
> 
> To summarize, if devs_in_pkg is zero, then (devs_in_pkg & 0x1fffffffU)
> == 0x1fffffffU can never be true, so the loop is never iterated over.
> 
> Colin

You are absolutely correct. The check should have been || and not &&.
I have a patch in my tree where I am fixing that. I was giving it some
more thorough testing to understand why it was working, though, and how
I could've missed it. One hypothesis I can't rule out is that I tested
it using || but submitted it using && somehow (although I don't remember
doing that).

Thanks,
-Vladimir

      reply	other threads:[~2020-07-20 16:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 16:21 net: phy: continue searching for C45 MMDs even if first returned ffff:ffff Colin Ian King
2020-07-20 16:31 ` Vladimir Oltean [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=20200720163121.sihkkncthvwnfqd7@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.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