* re: net: phy: continue searching for C45 MMDs even if first returned ffff:ffff
@ 2020-07-20 16:21 Colin Ian King
2020-07-20 16:31 ` Vladimir Oltean
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2020-07-20 16:21 UTC (permalink / raw)
To: Vladimir Oltean, Andrew Lunn, Florian Fainelli, Heiner Kallweit,
Russell King, David S. Miller, Jakub Kicinski, netdev
Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: net: phy: continue searching for C45 MMDs even if first returned ffff:ffff
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
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Oltean @ 2020-07-20 16:31 UTC (permalink / raw)
To: Colin Ian King
Cc: Vladimir Oltean, Andrew Lunn, Florian Fainelli, Heiner Kallweit,
Russell King, David S. Miller, Jakub Kicinski, netdev,
linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-20 16:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).