From nobody Thu Apr 9 23:23:24 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DE3D6378D9E for ; Thu, 5 Mar 2026 10:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772706493; cv=none; b=lbmvlkL3KHCEXxKDeO0ws3QLWioRVUsRpR0NqZdVTk+zL54YixJvZe8plXSHTYSnDml4IpeLafVHFCf7es/YmAfiyC3B2cPPO19VDNgNJPhZd2S8j2F82GKnes4nJ3MAZF4le8L+rtON7dWKSchPkjcqJxkCxmjAihuEaK41hoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772706493; c=relaxed/simple; bh=0p6cIf6F7KV5IKmj35qkuAVhHsBk2rNQyv72t1IatkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fjbnmjaTn9bIsi6snV1Ej1A6L9NqJln5qeK9HDXaG1bBEq6uU9PUnIsyLs/5LT0uWWkic2UuMnnKE35g4hPkDQuk8qtP53YhdITw7Kps6DaWbPXLAILdGubvpBkq5chLVVgaW+HIe1FD9kOFxl1a/8qNyF7/ccTydeMIfLJUu9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lJe/B5ny; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lJe/B5ny" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B936C2BCAF; Thu, 5 Mar 2026 10:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772706493; bh=0p6cIf6F7KV5IKmj35qkuAVhHsBk2rNQyv72t1IatkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJe/B5nyPeMKLwApAj8TwUBnTARIUAuXI9Y2Ect8Gd/fVOHEDFl5neNsegtgQ7Z7b iutuQfjSuv3vY7yCkef0GiszsVFre9JVClYcvoLeCLLJ5JQ+rusSexG6Z424bhE6U/ JJ4o7fRwAFAeRAc9ldSfDOeIpc4NM/+V0rbTVc1hayL+YXzvADS/Be9AqjDOT4f8AY fJun/tQjQvfbkF8fcvsh6/AwuaeA5R7KiQ31CepMLG1h+q3VpGaKeQESzA3b3Pjywz H5kMaq9LZ/+HceNlfJiLQr+Z7WSO8k3zDNaVHWTvFTdLX3JyK9r0UQJFv1UafEZA89 71osD21g8gfmQ== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vy5wB-0000000038f-0HzI; Thu, 05 Mar 2026 11:28:11 +0100 From: Johan Hovold To: Dave Penkler Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/2] gpib: agilent_82357a: drop redundant device reference Date: Thu, 5 Mar 2026 11:27:44 +0100 Message-ID: <20260305102745.12032-2-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260305102745.12032-1-johan@kernel.org> References: <20260305102745.12032-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- drivers/gpib/agilent_82357a/agilent_82357a.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpib/agilent_82357a/agilent_82357a.c b/drivers/gpib/ag= ilent_82357a/agilent_82357a.c index e1349afbf933..770ba6eb40d1 100644 --- a/drivers/gpib/agilent_82357a/agilent_82357a.c +++ b/drivers/gpib/agilent_82357a/agilent_82357a.c @@ -1479,7 +1479,7 @@ static int agilent_82357a_driver_probe(struct usb_int= erface *interface, =20 if (mutex_lock_interruptible(&agilent_82357a_hotplug_lock)) return -ERESTARTSYS; - usb_dev =3D usb_get_dev(interface_to_usbdev(interface)); + usb_dev =3D interface_to_usbdev(interface); for (i =3D 0; i < MAX_NUM_82357A_INTERFACES; ++i) { if (!agilent_82357a_driver_interfaces[i]) { agilent_82357a_driver_interfaces[i] =3D interface; @@ -1490,14 +1490,12 @@ static int agilent_82357a_driver_probe(struct usb_i= nterface *interface, } } if (i =3D=3D MAX_NUM_82357A_INTERFACES) { - usb_put_dev(usb_dev); mutex_unlock(&agilent_82357a_hotplug_lock); dev_err(&usb_dev->dev, "out of space in agilent_82357a_driver_interfaces= []\n"); return -1; } path =3D kmalloc(path_length, GFP_KERNEL); if (!path) { - usb_put_dev(usb_dev); mutex_unlock(&agilent_82357a_hotplug_lock); return -ENOMEM; } @@ -1539,7 +1537,6 @@ static void agilent_82357a_driver_disconnect(struct u= sb_interface *interface) } if (i =3D=3D MAX_NUM_82357A_INTERFACES) dev_err(&usb_dev->dev, "unable to find interface - bug?\n"); - usb_put_dev(usb_dev); =20 mutex_unlock(&agilent_82357a_hotplug_lock); } --=20 2.52.0 From nobody Thu Apr 9 23:23:24 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DE35634D91C for ; Thu, 5 Mar 2026 10:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772706493; cv=none; b=D9nmSIkj1bqndmbQ8IueywiyY3THGJPoKowlvEllwQ8WCKp43nN6BtxFHQEB9Jh3mISwvkbQ6mkLrFCX0SqwJoOCiCpgt8ww32so9H6GyS1E4iesv2zgdgl9Tue4gvHnSagEHYR/JRJYHKn+VVFQK2PETvo2rn4UctUulzcnt68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772706493; c=relaxed/simple; bh=oTfXeQlgSIRACb79WdBJDW6H2C6byOd6tnYlFNKWdgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NC27s7Hs362ga0MMeV35VxBA60Du2+RG5RM/L9l2Fa3qsO29oi/I9EwhZLqowcClbHprMZDGPhpNRKhjyD4cXLqJCN7x0adMRZHNSNG9H3rIJCQmyLEIxTcFK9/15Ro+pXckutdR94YvRzzg/YWXWFxWjOVK51pqZGCKVUhc0a4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n0fuTk3W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n0fuTk3W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 887AFC2BC9E; Thu, 5 Mar 2026 10:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772706493; bh=oTfXeQlgSIRACb79WdBJDW6H2C6byOd6tnYlFNKWdgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0fuTk3WxVNIhKvFI1irZIiPTELm+yhD9yTKVnC3NHhP0PRoXZB/xKApzQ7LI1ytY j5gN6wY7o0EoDQ6DlbVEZGB5DHuG+pHV08TA55FDdEsn5aQ3tmewUw4YGkggsNQ9yy e6iVn8XMHNfnFXSecsD/8kwoW9C4MAeupL9VTghLPu+2F/9DcDG0nZ+LC7eyYqPYzd 8tQIE7dLRlMAhYWmh+YB5cNR40hCgCHMImPpPLcbyT3e3t0ig5vPVF/jTPPgEZ3sot yMS2idZNNtC/3fuFM2nVa0YTjlB0DZmIQMgk4nBAFseA8PXmOtQNHwnkk4RVEK7SnE cSOetRzDbdxmg== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vy5wB-0000000038i-0KZc; Thu, 05 Mar 2026 11:28:11 +0100 From: Johan Hovold To: Dave Penkler Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/2] gpib: ni_usb: drop redundant device reference Date: Thu, 5 Mar 2026 11:27:45 +0100 Message-ID: <20260305102745.12032-3-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260305102745.12032-1-johan@kernel.org> References: <20260305102745.12032-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- drivers/gpib/ni_usb/ni_usb_gpib.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/gpib/ni_usb/ni_usb_gpib.c b/drivers/gpib/ni_usb/ni_usb= _gpib.c index a24cd6521362..0bbc13ecebf9 100644 --- a/drivers/gpib/ni_usb/ni_usb_gpib.c +++ b/drivers/gpib/ni_usb/ni_usb_gpib.c @@ -2431,7 +2431,6 @@ static int ni_usb_driver_probe(struct usb_interface *= interface, const struct usb static const int path_length =3D 1024; =20 mutex_lock(&ni_usb_hotplug_lock); - usb_get_dev(usb_dev); for (i =3D 0; i < MAX_NUM_NI_USB_INTERFACES; i++) { if (!ni_usb_driver_interfaces[i]) { ni_usb_driver_interfaces[i] =3D interface; @@ -2440,14 +2439,12 @@ static int ni_usb_driver_probe(struct usb_interface= *interface, const struct usb } } if (i =3D=3D MAX_NUM_NI_USB_INTERFACES) { - usb_put_dev(usb_dev); mutex_unlock(&ni_usb_hotplug_lock); dev_err(&usb_dev->dev, "ni_usb_driver_interfaces[] full\n"); return -1; } path =3D kmalloc(path_length, GFP_KERNEL); if (!path) { - usb_put_dev(usb_dev); mutex_unlock(&ni_usb_hotplug_lock); return -ENOMEM; } @@ -2488,7 +2485,6 @@ static void ni_usb_driver_disconnect(struct usb_inter= face *interface) } if (i =3D=3D MAX_NUM_NI_USB_INTERFACES) dev_err(&usb_dev->dev, "unable to find interface bug?\n"); - usb_put_dev(usb_dev); mutex_unlock(&ni_usb_hotplug_lock); } =20 --=20 2.52.0