[PATCH 10/13] wifi: rt2x00: drop redundant device reference

Stanislaw Gruszka stf_xl at wp.pl
Thu Mar 5 08:52:52 PST 2026


On Thu, Mar 05, 2026 at 12:07:10PM +0100, Johan Hovold wrote:
> 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 <johan at kernel.org>
Acked-by: Stanislaw Gruszka <stf_xl at wp.pl>

> ---
>  drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
> index 54599cad78f9..83d00b6baf64 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
> @@ -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);
>  
> -- 
> 2.52.0
> 



More information about the libertas-dev mailing list