wifi: plfxlc: Fix error handling in usb driver probe
authorMurad Masimov <m.masimov@mt-integration.ru>
Fri, 21 Mar 2025 18:52:26 +0000 (21:52 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 18 Jul 2025 12:23:23 +0000 (14:23 +0200)
commit3fe79a25c3cd54d25d30bc235c0c57f8a123d9d5
tree3307d12262d1ab254115f9d7b4c58efd77d2fa0f
parentf8bf97ad19c48f5e66cf99bd390356ffa1189d62
wifi: plfxlc: Fix error handling in usb driver probe

If probe fails before ieee80211_register_hw() is successfully done,
ieee80211_unregister_hw() will be called anyway. This may lead to various
bugs as the implementation of ieee80211_unregister_hw() assumes that
ieee80211_register_hw() has been called.

Divide error handling section into relevant subsections, so that
ieee80211_unregister_hw() is called only when it is appropriate. Correct
the order of the calls: ieee80211_unregister_hw() should go before
plfxlc_mac_release(). Also move ieee80211_free_hw() to plfxlc_mac_release()
as it supposed to be the opposite to plfxlc_mac_alloc_hw() that calls
ieee80211_alloc_hw().

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

Fixes: 68d57a07bfe5 ("wireless: add plfxlc driver for pureLiFi X, XL, XC devices")
Signed-off-by: Murad Masimov <m.masimov@mt-integration.ru>
Link: https://patch.msgid.link/20250321185226.71-3-m.masimov@mt-integration.ru
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/purelifi/plfxlc/mac.c
drivers/net/wireless/purelifi/plfxlc/mac.h
drivers/net/wireless/purelifi/plfxlc/usb.c