wifi: drop redundant USB device references
Subsystems (15)
v2 cover wifi: drop redundant USB device references
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
Note that I sent an ath9k patch separately here:
https://lore.kernel.org/all/[email protected]/
but I included it here in v2 for completeness.
Also note that Greg had already sent a fix for rtw88 which has been picked up by Ping-Ke, but who asked me to send a replacement. If an incremental patch is preferred I can instead send a follow up for that one later.
Johan
Changes in v2:
- include ath9k, previously submitted separately
- include ath6kl and ath10k
- rename the ath6kl and ath10k disconnect callbacks
- fix a reference leak in rtw88 previously reported (and fixed differently) by Greg
Johan Hovold (18):
wifi: ath6kl: drop redundant device reference
wifi: ath6kl: rename disconnect callback
wifi: ath9k: drop redundant device reference
wifi: ath10k: drop redundant device reference
wifi: ath10k: rename disconnect callback
wifi: at76c50x: drop redundant device reference
wifi: libertas: drop redundant device reference
wifi: libertas_tf: drop redundant device reference
wifi: mwifiex: drop redundant device reference
wifi: mt76: drop redundant device reference
wifi: mt76x0u: drop redundant device reference
wifi: mt76x2u: drop redundant device reference
wifi: mt76: mt792xu: drop redundant device reference
wifi: mt7601u: drop redundant device reference
wifi: rt2x00: drop redundant device reference
wifi: rtl818x: drop redundant device reference
wifi: rtl8xxxu: drop redundant device reference
wifi: rtw88: fix device leak on probe failure
drivers/net/wireless/ath/ath10k/usb.c | 8 ++------ drivers/net/wireless/ath/ath6kl/usb.c | 16 ++++------------ drivers/net/wireless/ath/ath9k/hif_usb.c | 4 ---- drivers/net/wireless/atmel/at76c50x-usb.c | 12 ++++-------- drivers/net/wireless/marvell/libertas/if_usb.c | 3 --- .../net/wireless/marvell/libertas_tf/if_usb.c | 2 -- drivers/net/wireless/marvell/mwifiex/usb.c | 4 ---- drivers/net/wireless/mediatek/mt76/mt7615/usb.c | 3 --- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 3 --- drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | 4 ---- drivers/net/wireless/mediatek/mt76/mt7921/usb.c | 2 -- drivers/net/wireless/mediatek/mt76/mt7925/usb.c | 2 -- drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 1 - drivers/net/wireless/mediatek/mt7601u/usb.c | 3 --- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 12 +----------- .../net/wireless/realtek/rtl818x/rtl8187/dev.c | 4 ---- drivers/net/wireless/realtek/rtl8xxxu/core.c | 11 +++-------- drivers/net/wireless/realtek/rtw88/usb.c | 3 +-- 18 files changed, 15 insertions(+), 82 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/18 wifi: ath6kl: drop redundant device reference
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/ath/ath6kl/usb.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath6kl/usb.c +2 -10
@@ -1124,8 +1124,6 @@ static int ath6kl_usb_probe(struct usb_interface *interface,int vendor_id, product_id;int ret =0 ; -usb_get_dev (dev); - vendor_id =le16_to_cpu (dev->descriptor.idVendor); product_id =le16_to_cpu (dev->descriptor.idProduct);
@@ -1143,11 +1141,8 @@ static int ath6kl_usb_probe(struct usb_interface *interface,ath6kl_dbg (ATH6KL_DBG_USB ,"USB 1.1 Host\n" ); ar_usb =ath6kl_usb_create (interface); - -if (ar_usb ==NULL ) { - ret = -ENOMEM ; - goto err_usb_put; - } +if (ar_usb ==NULL ) +return -ENOMEM ; ar =ath6kl_core_create (&ar_usb->udev->dev);if (ar ==NULL ) {
@@ -1176,15 +1171,12 @@ static int ath6kl_usb_probe(struct usb_interface *interface,ath6kl_core_destroy (ar); err_usb_destroy:ath6kl_usb_destroy (ar_usb); -err_usb_put: -usb_put_dev (dev);return ret; }static void ath6kl_usb_remove (struct usb_interface *interface) { -usb_put_dev (interface_to_usbdev (interface));ath6kl_usb_device_detached (interface); }
Signature · 1 line
2.52.0
PATCH v2 2/18 wifi: ath6kl: rename disconnect callback
In reply to Johan HovoldRename the disconnect callback so that it reflects the callback name for consistency with the rest of the kernel (e.g. makes it easier to grep for).
--- drivers/net/wireless/ath/ath6kl/usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/usb.c +2 -2
@@ -1175,7 +1175,7 @@ static int ath6kl_usb_probe(struct usb_interface *interface,return ret; } -static void ath6kl_usb_remove (struct usb_interface *interface) +static void ath6kl_usb_disconnect (struct usb_interface *interface) {ath6kl_usb_device_detached (interface); }
@@ -1227,7 +1227,7 @@ static struct usb_driver ath6kl_usb_driver = { .probe = ath6kl_usb_probe, .suspend = ath6kl_usb_pm_suspend, .resume = ath6kl_usb_pm_resume, - .disconnect = ath6kl_usb_remove, + .disconnect = ath6kl_usb_disconnect, .id_table = ath6kl_usb_ids, .supports_autosuspend = true, .disable_hub_initiated_lpm = 1,
Signature · 1 line
2.52.0
PATCH v2 3/18 wifi: ath9k: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +0 -4
@@ -1382,8 +1382,6 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface, goto err_alloc; } -usb_get_dev (udev); - hif_dev->udev = udev; hif_dev->interface = interface; hif_dev->usb_device_id = id;
@@ -1403,7 +1401,6 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface, err_fw_req:usb_set_intfdata (interface,NULL );kfree (hif_dev); -usb_put_dev (udev); err_alloc:return ret; }
@@ -1451,7 +1448,6 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface)kfree (hif_dev);dev_info (&udev->dev,"ath9k_htc: USB layer deinitialized\n" ); -usb_put_dev (udev); }#ifdef CONFIG_PM
Signature · 1 line
2.52.0
Re: [PATCH v2 03/18] wifi: ath9k: drop redundant device reference
Quoted 10 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
Signed-off-by Johan Hovold <[email protected]>
PATCH v2 4/18 wifi: ath10k: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/ath/ath10k/usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/ath/ath10k/usb.c +0 -4
@@ -1016,7 +1016,6 @@ static int ath10k_usb_probe(struct usb_interface *interface,netif_napi_add (ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); -usb_get_dev (dev); vendor_id =le16_to_cpu (dev->descriptor.idVendor); product_id =le16_to_cpu (dev->descriptor.idProduct);
@@ -1055,8 +1054,6 @@ static int ath10k_usb_probe(struct usb_interface *interface, err:ath10k_core_destroy (ar); -usb_put_dev (dev); -return ret; }
@@ -1071,7 +1068,6 @@ static void ath10k_usb_remove(struct usb_interface *interface)ath10k_core_unregister (ar_usb->ar);netif_napi_del (&ar_usb->ar->napi);ath10k_usb_destroy (ar_usb->ar); -usb_put_dev (interface_to_usbdev (interface));ath10k_core_destroy (ar_usb->ar); }
Signature · 1 line
2.52.0
PATCH v2 5/18 wifi: ath10k: rename disconnect callback
In reply to Johan HovoldRename the disconnect callback so that it reflects the callback name for consistency with the rest of the kernel (e.g. makes it easier to grep for).
--- drivers/net/wireless/ath/ath10k/usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/usb.c +2 -2
@@ -1057,7 +1057,7 @@ static int ath10k_usb_probe(struct usb_interface *interface,return ret; } -static void ath10k_usb_remove (struct usb_interface *interface) +static void ath10k_usb_disconnect (struct usb_interface *interface) {struct ath10k_usb *ar_usb;
@@ -1113,7 +1113,7 @@ static struct usb_driver ath10k_usb_driver = { .probe = ath10k_usb_probe, .suspend = ath10k_usb_pm_suspend, .resume = ath10k_usb_pm_resume, - .disconnect = ath10k_usb_remove, + .disconnect = ath10k_usb_disconnect, .id_table = ath10k_usb_ids, .supports_autosuspend = true, .disable_hub_initiated_lpm = 1,
Signature · 1 line
2.52.0
PATCH v2 6/18 wifi: at76c50x: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/atmel/at76c50x-usb.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/atmel/at76c50x-usb.c +4 -8
@@ -2440,13 +2440,11 @@ static int at76_probe(struct usb_interface *interface,struct mib_fw_version *fwv;int board_type = (int )id->driver_info; - udev =usb_get_dev (interface_to_usbdev (interface)); + udev =interface_to_usbdev (interface); fwv =kmalloc_obj (*fwv); -if (!fwv) { - ret = -ENOMEM ; - goto exit; - } +if (!fwv) +return -ENOMEM ;/* Load firmware into kernel memory */ fwe =at76_load_firmware (udev, board_type);
@@ -2534,8 +2532,7 @@ static int at76_probe(struct usb_interface *interface, exit:kfree (fwv); -if (ret <0 ) -usb_put_dev (udev); +return ret; }
@@ -2552,7 +2549,6 @@ static void at76_disconnect(struct usb_interface *interface)wiphy_info (priv->hw->wiphy,"disconnecting\n" );at76_delete_device (priv); -usb_put_dev (interface_to_usbdev (interface));dev_info (&interface->dev,"disconnected\n" ); }
Signature · 1 line
2.52.0
PATCH v2 7/18 wifi: libertas: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/marvell/libertas/if_usb.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/marvell/libertas/if_usb.c +0 -3
@@ -276,7 +276,6 @@ static int if_usb_probe(struct usb_interface *intf, cardp->boot2_version = udev->descriptor.bcdDevice; -usb_get_dev (udev);usb_set_intfdata (intf, cardp); r = lbs_get_firmware_async(priv, &udev->dev, cardp->model,
@@ -287,7 +286,6 @@ static int if_usb_probe(struct usb_interface *intf,return 0 ; err_get_fw: -usb_put_dev (udev);lbs_remove_card (priv); err_add_card:if_usb_reset_device (cardp);
@@ -321,7 +319,6 @@ static void if_usb_disconnect(struct usb_interface *intf)kfree (cardp);usb_set_intfdata (intf,NULL ); -usb_put_dev (interface_to_usbdev (intf)); }/**
Signature · 1 line
2.52.0
PATCH v2 8/18 wifi: libertas_tf: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/marvell/libertas_tf/if_usb.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/marvell/libertas_tf/if_usb.c +0 -2
@@ -223,7 +223,6 @@ static int if_usb_probe(struct usb_interface *intf,if (!priv) goto dealloc; -usb_get_dev (udev);usb_set_intfdata (intf, cardp);return 0 ;
@@ -258,7 +257,6 @@ static void if_usb_disconnect(struct usb_interface *intf)kfree (cardp);usb_set_intfdata (intf,NULL ); -usb_put_dev (interface_to_usbdev (intf));lbtf_deb_leave (LBTF_DEB_MAIN ); }
Signature · 1 line
2.52.0
PATCH v2 9/18 wifi: mwifiex: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/marvell/mwifiex/usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/marvell/mwifiex/usb.c +0 -4
@@ -520,8 +520,6 @@ static int mwifiex_usb_probe(struct usb_interface *intf,return ret; } -usb_get_dev (udev); -return 0 ; }
@@ -666,8 +664,6 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf)mwifiex_dbg (adapter,FATAL ,"%s: removing card\n" , __func__);mwifiex_remove_card (adapter); - -usb_put_dev (interface_to_usbdev (intf)); }static void mwifiex_usb_coredump (struct device *dev)
Signature · 1 line
2.52.0
PATCH v2 10/18 wifi: mt76: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/mediatek/mt76/mt7615/usb.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/usb.c +0 -3
@@ -151,7 +151,6 @@ static int mt7663u_probe(struct usb_interface *usb_intf,return -ENOMEM ; dev = container_of(mdev, struct mt7615_dev, mt76); - udev =usb_get_dev (udev);usb_reset_device (udev);usb_set_intfdata (usb_intf, dev);
@@ -193,7 +192,6 @@ static int mt7663u_probe(struct usb_interface *usb_intf, error:mt76u_queues_deinit (&dev->mt76);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76_free_device (&dev->mt76);
@@ -211,7 +209,6 @@ static void mt7663u_disconnect(struct usb_interface *usb_intf)mt7663u_cleanup (dev);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76_free_device (&dev->mt76); }
Signature · 1 line
2.52.0
PATCH v2 11/18 wifi: mt76x0u: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +0 -3
@@ -245,7 +245,6 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,if (id->driver_info) dev->no_2ghz = true; - usb_dev =usb_get_dev (usb_dev);usb_reset_device (usb_dev);usb_set_intfdata (usb_intf, dev);
@@ -284,7 +283,6 @@ static int mt76x0u_probe(struct usb_interface *usb_intf, err:usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76u_queues_deinit (&dev->mt76);mt76_free_device (&dev->mt76);
@@ -303,7 +301,6 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf)mt76x0u_cleanup (dev);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76_free_device (&dev->mt76); }
Signature · 1 line
2.52.0
PATCH v2 12/18 wifi: mt76x2u: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2/usb.c +0 -4
@@ -57,7 +57,6 @@ static int mt76x2u_probe(struct usb_interface *intf, dev = container_of(mdev, struct mt76x02_dev, mt76); - udev =usb_get_dev (udev);usb_reset_device (udev);usb_set_intfdata (intf, dev);
@@ -84,14 +83,12 @@ static int mt76x2u_probe(struct usb_interface *intf,mt76u_queues_deinit (&dev->mt76);mt76_free_device (&dev->mt76);usb_set_intfdata (intf,NULL ); -usb_put_dev (udev);return err; }static void mt76x2u_disconnect (struct usb_interface *intf) { -struct usb_device *udev =interface_to_usbdev (intf);struct mt76x02_dev *dev =usb_get_intfdata (intf);struct ieee80211_hw *hw =mt76_hw (dev);
@@ -100,7 +97,6 @@ static void mt76x2u_disconnect(struct usb_interface *intf)mt76x2u_cleanup (dev);mt76_free_device (&dev->mt76);usb_set_intfdata (intf,NULL ); -usb_put_dev (udev); } static int __maybe_unused mt76x2u_suspend(struct usb_interface *intf,
Signature · 1 line
2.52.0
PATCH v2 13/18 wifi: mt76: mt792xu: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/mediatek/mt76/mt7921/usb.c | 2 -- drivers/net/wireless/mediatek/mt76/mt7925/usb.c | 2 -- drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 1 - 3 files changed, 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/usb.c +0 -2
@@ -197,7 +197,6 @@ static int mt7921u_probe(struct usb_interface *usb_intf, dev->fw_features = features; dev->hif_ops = &hif_ops; - udev =usb_get_dev (udev);usb_reset_device (udev);usb_set_intfdata (usb_intf, dev);
@@ -246,7 +245,6 @@ static int mt7921u_probe(struct usb_interface *usb_intf,mt76u_queues_deinit (&dev->mt76);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76_free_device (&dev->mt76);
drivers/net/wireless/mediatek/mt76/mt7925/usb.c +0 -2
@@ -185,7 +185,6 @@ static int mt7925u_probe(struct usb_interface *usb_intf, dev->fw_features = features; dev->hif_ops = &hif_ops; - udev =usb_get_dev (udev);usb_reset_device (udev);usb_set_intfdata (usb_intf, dev);
@@ -234,7 +233,6 @@ static int mt7925u_probe(struct usb_interface *usb_intf,mt76u_queues_deinit (&dev->mt76);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76_free_device (&dev->mt76);
drivers/net/wireless/mediatek/mt76/mt792x_usb.c +0 -1
@@ -306,7 +306,6 @@ void mt792xu_disconnect(struct usb_interface *usb_intf)mt792xu_cleanup (dev);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));mt76_free_device (&dev->mt76); }
Signature · 1 line
2.52.0
PATCH v2 14/18 wifi: mt7601u: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/mediatek/mt7601u/usb.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/mediatek/mt7601u/usb.c +0 -3
@@ -274,7 +274,6 @@ static int mt7601u_probe(struct usb_interface *usb_intf,if (!dev)return -ENOMEM ; - usb_dev =usb_get_dev (usb_dev);usb_reset_device (usb_dev);usb_set_intfdata (usb_intf, dev);
@@ -319,7 +318,6 @@ static int mt7601u_probe(struct usb_interface *usb_intf,mt7601u_cleanup (dev); err:usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));destroy_workqueue (dev->stat_wq);ieee80211_free_hw (dev->hw);
@@ -334,7 +332,6 @@ static void mt7601u_disconnect(struct usb_interface *usb_intf)mt7601u_cleanup (dev);usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf));destroy_workqueue (dev->stat_wq);ieee80211_free_hw (dev->hw);
Signature · 1 line
2.52.0
PATCH v2 15/18 wifi: rt2x00: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +1 -11
@@ -802,14 +802,12 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,struct rt2x00_dev *rt2x00dev;int retval; - usb_dev =usb_get_dev (usb_dev);usb_reset_device (usb_dev); hw =ieee80211_alloc_hw (sizeof (struct rt2x00_dev ), ops->hw);if (!hw) {rt2x00_probe_err ("Failed to allocate hardware\n" ); - retval = -ENOMEM ; - goto exit_put_device; +return -ENOMEM ; }usb_set_intfdata (usb_intf, hw);
@@ -851,10 +849,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, exit_free_device:ieee80211_free_hw (hw); - -exit_put_device: -usb_put_dev (usb_dev); -usb_set_intfdata (usb_intf,NULL );return retval;
@@ -873,11 +867,7 @@ void rt2x00usb_disconnect(struct usb_interface *usb_intf)rt2x00usb_free_reg (rt2x00dev);ieee80211_free_hw (hw); -/* -* Free the USB device data. -*/ usb_set_intfdata (usb_intf,NULL ); -usb_put_dev (interface_to_usbdev (usb_intf)); }EXPORT_SYMBOL_GPL (rt2x00usb_disconnect);
Signature · 1 line
2.52.0
PATCH v2 16/18 wifi: rtl818x: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c +0 -4
@@ -1475,8 +1475,6 @@ static int rtl8187_probe(struct usb_interface *intf,usb_set_intfdata (intf, dev); priv->udev = udev; -usb_get_dev (udev); -skb_queue_head_init (&priv->rx_queue);BUILD_BUG_ON (sizeof (priv->channels) !=sizeof (rtl818x_channels));
@@ -1663,7 +1661,6 @@ static int rtl8187_probe(struct usb_interface *intf, err_free_dmabuf:kfree (priv->io_dmabuf);usb_set_intfdata (intf,NULL ); -usb_put_dev (udev); err_free_dev:ieee80211_free_hw (dev);return err;
@@ -1685,7 +1682,6 @@ static void rtl8187_disconnect(struct usb_interface *intf) priv = dev->priv;usb_reset_device (priv->udev); -usb_put_dev (interface_to_usbdev (intf));kfree (priv->io_dmabuf);ieee80211_free_hw (dev); }
Signature · 1 line
2.52.0
Ping-Ke Shih
maintainerRe: [PATCH v2 16/18] wifi: rtl818x: drop redundant device reference
Quoted 10 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
Signed-off-by Johan Hovold <[email protected]>
3 patch(es) applied to rtw-next branch of rtw.git, thanks.
68e7d359a5ee wifi: rtl818x: drop redundant device reference 711b8add3929 wifi: rtl8xxxu: drop redundant device reference bbb15e71156c wifi: rtw88: fix device leak on probe failure
PATCH v2 17/18 wifi: rtl8xxxu: drop redundant device reference
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/wireless/realtek/rtl8xxxu/core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/core.c +3 -8
@@ -7698,7 +7698,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,int ret;int untested =1 ; - udev =usb_get_dev (interface_to_usbdev (interface)); + udev =interface_to_usbdev (interface);switch (id->idVendor) {case USB_VENDOR_ID_REALTEK :
@@ -7756,10 +7756,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface, } hw =ieee80211_alloc_hw (sizeof (struct rtl8xxxu_priv ), &rtl8xxxu_ops); -if (!hw) { - ret = -ENOMEM ; - goto err_put_dev; - } +if (!hw) +return -ENOMEM ; priv = hw->priv; priv->hw = hw;
@@ -7901,8 +7899,6 @@ static int rtl8xxxu_probe(struct usb_interface *interface,mutex_destroy (&priv->h2c_mutex);ieee80211_free_hw (hw); -err_put_dev: -usb_put_dev (udev);return ret; }
@@ -7935,7 +7931,6 @@ static void rtl8xxxu_disconnect(struct usb_interface *interface) "Device still attached, trying to reset\n");usb_reset_device (priv->udev); } -usb_put_dev (priv->udev);ieee80211_free_hw (hw); }
Signature · 1 line
2.52.0
PATCH v2 18/18 wifi: rtw88: fix device leak on probe failure
In reply to Johan HovoldDriver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
This driver takes a reference to the USB device during probe but does not to release it on all probe errors (e.g. when descriptor parsing fails).
Drop the redundant device reference to fix the leak, reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of further memory leaks.
--- drivers/net/wireless/realtek/rtw88/usb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/usb.c +1 -2
@@ -1041,7 +1041,7 @@ static int rtw_usb_intf_init(struct rtw_dev *rtwdev, struct usb_interface *intf) {struct rtw_usb *rtwusb =rtw_get_usb_priv (rtwdev); -struct usb_device *udev =usb_get_dev (interface_to_usbdev (intf)); +struct usb_device *udev =interface_to_usbdev (intf);int ret; rtwusb->udev = udev;
@@ -1067,7 +1067,6 @@ static void rtw_usb_intf_deinit(struct rtw_dev *rtwdev, {struct rtw_usb *rtwusb =rtw_get_usb_priv (rtwdev); -usb_put_dev (rtwusb->udev);kfree (rtwusb->usb_data);usb_set_intfdata (intf,NULL ); }
Signature · 1 line
2.52.0
Quoted 62 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
Note that I sent an ath9k patch separately here:
https://lore.kernel.org/all/[email protected]/but I included it here in v2 for completeness.
Also note that Greg had already sent a fix for rtw88 which has been picked up by Ping-Ke, but who asked me to send a replacement. If an incremental patch is preferred I can instead send a follow up for that one later.
Johan
Changes in v2:
- include ath9k, previously submitted separately
- include ath6kl and ath10k
- rename the ath6kl and ath10k disconnect callbacks
- fix a reference leak in rtw88 previously reported (and fixed differently) by GregJohan Hovold (18):
wifi: ath6kl: drop redundant device reference
wifi: ath6kl: rename disconnect callback
wifi: ath9k: drop redundant device reference
wifi: ath10k: drop redundant device reference
wifi: ath10k: rename disconnect callback
wifi: at76c50x: drop redundant device reference
wifi: libertas: drop redundant device reference
wifi:libertas_tf: drop redundant device reference
wifi: mwifiex: drop redundant device reference
wifi: mt76: drop redundant device reference
wifi: mt76x0u: drop redundant device reference
wifi: mt76x2u: drop redundant device reference
wifi: mt76: mt792xu: drop redundant device reference
wifi: mt7601u: drop redundant device reference
wifi: rt2x00: drop redundant device reference
wifi: rtl818x: drop redundant device reference
wifi: rtl8xxxu: drop redundant device reference
wifi: rtw88: fix device leak on probe failuredrivers/net/wireless/ath/ath10k/usb.c | 8 ++------ drivers/net/wireless/ath/ath6kl/usb.c | 16 ++++------------ drivers/net/wireless/ath/ath9k/hif_usb.c | 4 ---- drivers/net/wireless/atmel/at76c50x-usb.c | 12 ++++-------- drivers/net/wireless/marvell/libertas/if_usb.c | 3 --- .../net/wireless/marvell/libertas_tf/if_usb.c | 2 -- drivers/net/wireless/marvell/mwifiex/usb.c | 4 ---- drivers/net/wireless/mediatek/mt76/mt7615/usb.c | 3 --- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 3 --- drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | 4 ---- drivers/net/wireless/mediatek/mt76/mt7921/usb.c | 2 --
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7925/usb.c | 2 -- drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 1 - drivers/net/wireless/mediatek/mt7601u/usb.c | 3 --- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 12 +----------- .../net/wireless/realtek/rtl818x/rtl8187/dev.c | 4 ---- drivers/net/wireless/realtek/rtl8xxxu/core.c | 11 +++-------- drivers/net/wireless/realtek/rtw88/usb.c | 3 +-- 18 files changed, 15 insertions(+), 82 deletions(-)
Johannes, will you be taking the entire series via wireless-next?
Or should the individual wireless driver maintainers take their patches through their individual trees? I'm OK either way.
/jeff
Johannes Berg
maintainerQuoted 5 lines · Jeff Johnson
Johannes, will you be taking the entire series via wireless-next?
Or should the individual wireless driver maintainers take their patches through their individual trees? I'm OK either way.
So far I took the ones patchwork had auto-assigned to me. I can take others though, no particular preference, but I guess I already pulled the series apart anyway.
Let's just say if you want me to take any, assign them to me in patchwork.
johannes
Quoted 7 lines · Johannes Berg
Quoted 5 lines · Jeff Johnson
Johannes, will you be taking the entire series via wireless-next?
Or should the individual wireless driver maintainers take their patches through their individual trees? I'm OK either way.
Quoted 6 lines
So far I took the ones patchwork had auto-assigned to me. I can take others though, no particular preference, but I guess I already pulled the series apart anyway.
Let's just say if you want me to take any, assign them to me in patchwork.
ok, then I'll go forward with the ones assigned to me...
/jeff
Jeff Johnson
AppliedRe: (subset) [PATCH v2 00/18] wifi: drop redundant USB device references
In reply to Johan HovoldQuoted 10 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
[...]
Applied, thanks!
[01/18] wifi: ath6kl: drop redundant device reference
commit: 86581adf05f526f53b90ebcbbc2fd4d9f9fd4c96
[02/18] wifi: ath6kl: rename disconnect callback
commit: 0bc013d68a5d1943728d110d759c6587c2b81913
[03/18] wifi: ath9k: drop redundant device reference
commit: 2ddbec82e1650d57ea0f63d284b5da01d2f21293
[04/18] wifi: ath10k: drop redundant device reference
commit: c880c0794076f04b0058dd5cbc1f94c33d7bff44
[05/18] wifi: ath10k: rename disconnect callback
commit: fcc3555fce3c35333891e904c3592375d5e63cf4Best regards,
Signature · 1 line
Jeff Johnson <[email protected]>
Quoted 9 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
Quoted 7 lines
Johan Hovold (18):
wifi: mt76: drop redundant device reference
wifi: mt76x0u: drop redundant device reference
wifi: mt76x2u: drop redundant device reference
wifi: mt76: mt792xu: drop redundant device reference
wifi: mt7601u: drop redundant device reference
All of these are now in linux-next except for the five Mediatek fixes.
Could someone pick them up as well? Not sure which tree they'd usually go through.
Johan
Ping-Ke Shih
maintainerHi Johan,
Quoted 18 lines · Johan Hovold
Quoted 9 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
Quoted 7 lines
Johan Hovold (18):
wifi: mt76: drop redundant device reference
wifi: mt76x0u: drop redundant device reference
wifi: mt76x2u: drop redundant device reference
wifi: mt76: mt792xu: drop redundant device reference
wifi: mt7601u: drop redundant device reference
Quoted 4 lines
All of these are now in linux-next except for the five Mediatek fixes.
Could someone pick them up as well? Not sure which tree they'd usually go through.
wifi: rtl818x: drop redundant device reference
wifi: rtl8xxxu: drop redundant device reference
wifi: rtw88: fix device leak on probe failure
Realtek WiFi got merged into my tree (not in linux-next yet), and I plan to send pull-request to wireless tree before 7.1 merge window.
Ping-Ke
Quoted 24 lines · Ping-Ke Shih
Quoted 18 lines · Johan Hovold
Quoted 9 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
Quoted 7 lines
Johan Hovold (18):
wifi: mt76: drop redundant device reference
wifi: mt76x0u: drop redundant device reference
wifi: mt76x2u: drop redundant device reference
wifi: mt76: mt792xu: drop redundant device reference
wifi: mt7601u: drop redundant device referenceQuoted 4 lines
All of these are now in linux-next except for the five Mediatek fixes.
Could someone pick them up as well? Not sure which tree they'd usually go through.
Quoted 6 lines
wifi: rtl818x: drop redundant device reference
wifi: rtl8xxxu: drop redundant device reference
wifi: rtw88: fix device leak on probe failureRealtek WiFi got merged into my tree (not in linux-next yet), and I plan to send pull-request to wireless tree before 7.1 merge window.
Yes, sorry, I forgot to mention that. I got a message about these having been picked up so I didn't include them in the list above. Thanks.
Johan
Quoted 18 lines · Johan Hovold
Quoted 9 lines · Johan Hovold
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop redundant device references to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release them.
Quoted 7 lines
Johan Hovold (18):
wifi: mt76: drop redundant device reference
wifi: mt76x0u: drop redundant device reference
wifi: mt76x2u: drop redundant device reference
wifi: mt76: mt792xu: drop redundant device reference
wifi: mt7601u: drop redundant device reference
Quoted 4 lines
All of these are now in linux-next except for the five Mediatek fixes.
Could someone pick them up as well? Not sure which tree they'd usually go through.
It's been two more weeks (and these haven't shown up in linux-next) so sending another reminder.
Can someone please pick these up for 7.1?
Johan