]> git.dujemihanovic.xyz Git - linux.git/commit
net: ethernet: ti: am65-cpsw: Fix mdio cleanup in probe
authorSiddharth Vadapalli <s-vadapalli@ti.com>
Mon, 3 Apr 2023 09:03:21 +0000 (14:33 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 4 Apr 2023 10:30:28 +0000 (12:30 +0200)
commitc6b486fb33680ad5a3a6390ce693c835caaae3f7
treecbafe976782f4f4da0629d3fc615fae88f9eb99d
parentea30388baebcce37fd594d425a65037ca35e59e8
net: ethernet: ti: am65-cpsw: Fix mdio cleanup in probe

In the am65_cpsw_nuss_probe() function's cleanup path, the call to
of_platform_device_destroy() for the common->mdio_dev device is invoked
unconditionally. It is possible that either the MDIO node is not present
in the device-tree, or the MDIO node is disabled in the device-tree. In
both these cases, the MDIO device is not created, resulting in a NULL
pointer dereference when the of_platform_device_destroy() function is
invoked on the common->mdio_dev device on the cleanup path.

Fix this by ensuring that the common->mdio_dev device exists, before
attempting to invoke of_platform_device_destroy().

Fixes: a45cfcc69a25 ("net: ethernet: ti: am65-cpsw-nuss: use of_platform_device_create() for mdio")
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Link: https://lore.kernel.org/r/20230403090321.835877-1-s-vadapalli@ti.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/ti/am65-cpsw-nuss.c