[PATCH 2/2] wifi: mt7601u: remove debugfs directory on disconnect
From: Wang Jikai
Date: Thu Apr 20 2023 - 09:11:34 EST
Debugfs is created during device init but not removed.
Add a function mt7601u_remove_debugfs to remove debugfs
when the device disconnects.
Fixes: c869f77d6abb ("add mt7601u driver")
Signed-off-by: Wang Jikai <wangjikai@xxxxxxxxxxx>
---
The issue is found by static analysis and remains untested.
---
drivers/net/wireless/mediatek/mt7601u/debugfs.c | 5 +++++
drivers/net/wireless/mediatek/mt7601u/mt7601u.h | 1 +
drivers/net/wireless/mediatek/mt7601u/usb.c | 1 +
3 files changed, 7 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt7601u/debugfs.c b/drivers/net/wireless/mediatek/mt7601u/debugfs.c
index dbddf256921b..1b87a4854e0e 100644
--- a/drivers/net/wireless/mediatek/mt7601u/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt7601u/debugfs.c
@@ -136,3 +136,8 @@ void mt7601u_init_debugfs(struct mt7601u_dev *dev)
debugfs_create_file("ampdu_stat", 0400, dir, dev, &mt7601u_ampdu_stat_fops);
debugfs_create_file("eeprom_param", 0400, dir, dev, &mt7601u_eeprom_param_fops);
}
+
+void mt7601u_remove_debugfs(struct mt7601u_dev *dev)
+{
+ debugfs_lookup_and_remove("mt7601u", dev->hw->wiphy->debugfsdir);
+}
diff --git a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h
index 118d43707853..0216ace4b8e9 100644
--- a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h
+++ b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h
@@ -279,6 +279,7 @@ struct mt7601u_rxwi;
extern const struct ieee80211_ops mt7601u_ops;
void mt7601u_init_debugfs(struct mt7601u_dev *dev);
+void mt7601u_remove_debugfs(struct mt7601u_dev *dev);
u32 mt7601u_rr(struct mt7601u_dev *dev, u32 offset);
void mt7601u_wr(struct mt7601u_dev *dev, u32 offset, u32 val);
diff --git a/drivers/net/wireless/mediatek/mt7601u/usb.c b/drivers/net/wireless/mediatek/mt7601u/usb.c
index cc772045d526..d9a93d05f1cf 100644
--- a/drivers/net/wireless/mediatek/mt7601u/usb.c
+++ b/drivers/net/wireless/mediatek/mt7601u/usb.c
@@ -332,6 +332,7 @@ static void mt7601u_disconnect(struct usb_interface *usb_intf)
ieee80211_unregister_hw(dev->hw);
mt7601u_cleanup(dev);
+ mt7601u_remove_debugfs(dev);
usb_set_intfdata(usb_intf, NULL);
usb_put_dev(interface_to_usbdev(usb_intf));
--
2.34.1