Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60f78652 authored by Corentin Labbe's avatar Corentin Labbe Committed by David S. Miller
Browse files

net: mdio-mux: fix unbalanced put_device



mdio_mux_uninit() call put_device (unconditionally) because of
of_mdio_find_bus() in mdio_mux_init.
But of_mdio_find_bus is only called if mux_bus is empty.
If mux_bus is set, mdio_mux_uninit will print a "refcount_t: underflow"
trace.

This patch add a get_device in the other branch of "if (mux_bus)".

Signed-off-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c642bbbc
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ int mdio_mux_init(struct device *dev,
	} else {
		parent_bus_node = NULL;
		parent_bus = mux_bus;
		get_device(&parent_bus->dev);
	}

	pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
@@ -184,8 +185,6 @@ int mdio_mux_init(struct device *dev,
	dev_err(dev, "Error: No acceptable child buses found\n");
	devm_kfree(dev, pb);
err_pb_kz:
	/* balance the reference of_mdio_find_bus() took */
	if (!mux_bus)
	put_device(&parent_bus->dev);
err_parent_bus:
	of_node_put(parent_bus_node);
@@ -204,7 +203,6 @@ void mdio_mux_uninit(void *mux_handle)
		cb = cb->next;
	}

	/* balance the reference of_mdio_find_bus() in mdio_mux_init() took */
	put_device(&pb->mii_bus->dev);
}
EXPORT_SYMBOL_GPL(mdio_mux_uninit);