From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FC98313540 for ; Thu, 5 Mar 2026 16:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.77.101.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772729578; cv=none; b=jbdznZOQjy4KB8dcYCFBgOGJrScz5C2/IebsB2ftXfkZWe+OgfBV0Y0Zu7V8mTytS6Y2lL15nZ2S/x0IdIdMxc6TVF/QMnDLOJAIzW974QWEth+hlCYwmYWQmYnDPGD0KT9cBJB5cKmPmhCgK/Bik1C2JozwwarkOgmwsvFjCLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772729578; c=relaxed/simple; bh=lPd3xRfvHNfLIITtOH+GVXIOfyrNlvjQZbC9rkyCTAw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sXzy7Ma7PStPl3eg6/mbXSsVmaeRBDoJeuc1ujjN1vHnicmAmP+CaKwPlQ8kMmxERILtxhbRXzXE0GzLC4FRlDgFsedTkqcpjBTyFJyLPzXI0bTPGh9rM4CU/IwtWf7sQ0AqL6Mc8uV73HuXnIupes27uEk05d6ZLCSkoM9Lrvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b=yjfLtIO8; arc=none smtp.client-ip=212.77.101.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b="yjfLtIO8" Received: (wp-smtpd smtp.wp.pl 3648 invoked from network); 5 Mar 2026 17:52:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=20241105; t=1772729572; bh=nceW5alBsceTqsHbyHEzTPEtOGIiCOQeWI18n7irs4s=; h=From:To:Cc:Subject; b=yjfLtIO82yWWGrGfJJKkOyGgY6YMAghLBA0DPoVtoRr0txyusYsRE2erOvh6epnV9 SfdGLtnq5Z10wg4I0P1ww0xWOeXk/OLwE3ABPO8jW9YudoEgRVQmRnScs2O8a4z0Ld L0x9eaU7bGwPww/KP4U1vsKJnwgmnZGpoSx1tnlTNNZUUPdoOSFYyTayxfm9D67sju O7QSSbYUzAVxrCLWIJ9SK8Krfj518PCqho/5PYkwSU6K3Ke17jA12Jp5z4fNR/RUwA E7yczLQnmUJK6rj+jOX1MX8m3bmNaOv0UkDKP6T6Xo54eOM3s2eE22B0eXk+tmc3FH Nm41AGQXONXcQ== Received: from 77-236-11-252.static.play.pl (HELO localhost) (stf_xl@wp.pl@[77.236.11.252]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with TLS_AES_256_GCM_SHA384 encrypted SMTP for ; 5 Mar 2026 17:52:52 +0100 Date: Thu, 5 Mar 2026 17:52:52 +0100 From: Stanislaw Gruszka To: Johan Hovold Cc: linux-wireless@vger.kernel.org, Brian Norris , Francesco Dolcini , Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Jakub Kicinski , Hin-Tak Leung , Jes Sorensen , Ping-Ke Shih , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Matthias Brugger , AngeloGioacchino Del Regno , libertas-dev@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/13] wifi: rt2x00: drop redundant device reference Message-ID: <20260305165252.GA77369@wp.pl> References: <20260305110713.17725-1-johan@kernel.org> <20260305110713.17725-11-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260305110713.17725-11-johan@kernel.org> X-WP-MailID: 7399742c24ade6edd38c91daa616f014 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [0TOR] 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 Acked-by: Stanislaw Gruszka > --- > 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 >