re: net: phy: continue searching for C45 MMDs even if first returned ffff:ffff

From: Colin Ian King
Date: Mon Jul 20 2020 - 12:21:23 EST


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@xxxxxxx>
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