Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: rt2x00: 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.

Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260306085144.12064-16-johan@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Johan Hovold and committed by
Johannes Berg
6f29eda7 b1af0de3

+1 -11
+1 -11
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
··· 802 802 struct rt2x00_dev *rt2x00dev; 803 803 int retval; 804 804 805 - usb_dev = usb_get_dev(usb_dev); 806 805 usb_reset_device(usb_dev); 807 806 808 807 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw); 809 808 if (!hw) { 810 809 rt2x00_probe_err("Failed to allocate hardware\n"); 811 - retval = -ENOMEM; 812 - goto exit_put_device; 810 + return -ENOMEM; 813 811 } 814 812 815 813 usb_set_intfdata(usb_intf, hw); ··· 849 851 850 852 exit_free_device: 851 853 ieee80211_free_hw(hw); 852 - 853 - exit_put_device: 854 - usb_put_dev(usb_dev); 855 - 856 854 usb_set_intfdata(usb_intf, NULL); 857 855 858 856 return retval; ··· 867 873 rt2x00usb_free_reg(rt2x00dev); 868 874 ieee80211_free_hw(hw); 869 875 870 - /* 871 - * Free the USB device data. 872 - */ 873 876 usb_set_intfdata(usb_intf, NULL); 874 - usb_put_dev(interface_to_usbdev(usb_intf)); 875 877 } 876 878 EXPORT_SYMBOL_GPL(rt2x00usb_disconnect); 877 879