[lvc-project] [PATCH] net: sfp: remove redundant NULL check

Daniil Dulov d.dulov at aladdin.ru
Sun Feb 11 18:08:24 MSK 2024


bus->upstream_ops in sfp_register_bus() cannot be NULL. So remove
redundant NULL check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices and sfp cages")
Signed-off-by: Daniil Dulov <d.dulov at aladdin.ru>
---
 drivers/net/phy/sfp-bus.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index 850915a37f4c..829cb1dccc27 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -478,14 +478,12 @@ static int sfp_register_bus(struct sfp_bus *bus)
 	const struct sfp_upstream_ops *ops = bus->upstream_ops;
 	int ret;
 
-	if (ops) {
-		if (ops->link_down)
-			ops->link_down(bus->upstream);
-		if (ops->connect_phy && bus->phydev) {
-			ret = ops->connect_phy(bus->upstream, bus->phydev);
-			if (ret)
-				return ret;
-		}
+	if (ops->link_down)
+		ops->link_down(bus->upstream);
+	if (ops->connect_phy && bus->phydev) {
+		ret = ops->connect_phy(bus->upstream, bus->phydev);
+		if (ret)
+			return ret;
 	}
 	bus->registered = true;
 	bus->socket_ops->attach(bus->sfp);
-- 
2.25.1




More information about the lvc-project mailing list