lbs_add_mesh() stores the new mesh device in priv->mesh_dev before it calls register_netdev(). If the registration fails, the device is freed but priv->mesh_dev still points to it. Neither caller, lbs_start_mesh() nor the lbs_mesh sysfs store, checks the return value, so the driver keeps using the freed device: the RX, TX completion and multicast paths dereference it, and lbs_remove_mesh() later unregisters it and frees it and its wireless_dev a second time. Clear priv->mesh_dev on the error path. Fixes: 23a397ac821a ("libertas: add lbs_mesh sysfs attribute for enabling mesh") Signed-off-by: Yuho Choi --- Compile-tested only (x86_64, LIBERTAS_USB=m, LIBERTAS_MESH=y; mesh.o is clean with W=1). I don't have Libertas hardware, and register_netdev() only fails here on an allocation failure or a notifier veto, so I could not trigger this path. drivers/net/wireless/marvell/libertas/mesh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/marvell/libertas/mesh.c b/drivers/net/wireless/marvell/libertas/mesh.c index 686b2e18a0e9..94e346947552 100644 --- a/drivers/net/wireless/marvell/libertas/mesh.c +++ b/drivers/net/wireless/marvell/libertas/mesh.c @@ -528,6 +528,7 @@ static int lbs_add_mesh(struct lbs_private *priv) goto done; err_free_netdev: + priv->mesh_dev = NULL; free_netdev(mesh_dev); err_free_wdev: base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23 -- 2.56.1