public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] nfc: drop redundant USB device references
@ 2026-03-05 11:10 Johan Hovold
  2026-03-05 11:10 ` [PATCH 1/2] nfc: pn533: drop redundant device reference Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johan Hovold @ 2026-03-05 11:10 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: linux-kernel, 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.

Johan


Johan Hovold (2):
  nfc: pn533: drop redundant device reference
  nfc: port100: drop redundant device reference

 drivers/nfc/pn533/usb.c | 4 +---
 drivers/nfc/port100.c   | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] nfc: pn533: drop redundant device reference
  2026-03-05 11:10 [PATCH 0/2] nfc: drop redundant USB device references Johan Hovold
@ 2026-03-05 11:10 ` Johan Hovold
  2026-03-05 11:10 ` [PATCH 2/2] nfc: port100: " Johan Hovold
  2026-03-07  3:10 ` [PATCH 0/2] nfc: drop redundant USB device references patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2026-03-05 11:10 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: linux-kernel, 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 <johan@kernel.org>
---
 drivers/nfc/pn533/usb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index 0f12f86ebb02..0ff2f0d7caf4 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -500,7 +500,7 @@ static int pn533_usb_probe(struct usb_interface *interface,
 	if (!in_buf)
 		return -ENOMEM;
 
-	phy->udev = usb_get_dev(interface_to_usbdev(interface));
+	phy->udev = interface_to_usbdev(interface);
 	phy->interface = interface;
 
 	iface_desc = interface->cur_altsetting;
@@ -600,7 +600,6 @@ static int pn533_usb_probe(struct usb_interface *interface,
 	usb_free_urb(phy->in_urb);
 	usb_free_urb(phy->out_urb);
 	usb_free_urb(phy->ack_urb);
-	usb_put_dev(phy->udev);
 	kfree(in_buf);
 	kfree(phy->ack_buffer);
 
@@ -628,7 +627,6 @@ static void pn533_usb_disconnect(struct usb_interface *interface)
 	usb_free_urb(phy->out_urb);
 	usb_free_urb(phy->ack_urb);
 	kfree(phy->ack_buffer);
-	usb_put_dev(phy->udev);
 
 	nfc_info(&interface->dev, "NXP PN533 NFC device disconnected\n");
 }
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] nfc: port100: drop redundant device reference
  2026-03-05 11:10 [PATCH 0/2] nfc: drop redundant USB device references Johan Hovold
  2026-03-05 11:10 ` [PATCH 1/2] nfc: pn533: drop redundant device reference Johan Hovold
@ 2026-03-05 11:10 ` Johan Hovold
  2026-03-07  3:10 ` [PATCH 0/2] nfc: drop redundant USB device references patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2026-03-05 11:10 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: linux-kernel, 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 <johan@kernel.org>
---
 drivers/nfc/port100.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index a922569d7b48..09dcc6f4c4f3 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -1504,7 +1504,7 @@ static int port100_probe(struct usb_interface *interface,
 		return -ENOMEM;
 
 	mutex_init(&dev->out_urb_lock);
-	dev->udev = usb_get_dev(interface_to_usbdev(interface));
+	dev->udev = interface_to_usbdev(interface);
 	dev->interface = interface;
 	usb_set_intfdata(interface, dev);
 
@@ -1616,7 +1616,6 @@ static int port100_probe(struct usb_interface *interface,
 	usb_free_urb(dev->in_urb);
 	usb_kill_urb(dev->out_urb);
 	usb_free_urb(dev->out_urb);
-	usb_put_dev(dev->udev);
 
 	return rc;
 }
@@ -1636,7 +1635,6 @@ static void port100_disconnect(struct usb_interface *interface)
 
 	usb_free_urb(dev->in_urb);
 	usb_free_urb(dev->out_urb);
-	usb_put_dev(dev->udev);
 
 	kfree(dev->cmd);
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] nfc: drop redundant USB device references
  2026-03-05 11:10 [PATCH 0/2] nfc: drop redundant USB device references Johan Hovold
  2026-03-05 11:10 ` [PATCH 1/2] nfc: pn533: drop redundant device reference Johan Hovold
  2026-03-05 11:10 ` [PATCH 2/2] nfc: port100: " Johan Hovold
@ 2026-03-07  3:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-07  3:10 UTC (permalink / raw)
  To: Johan Hovold; +Cc: kuba, netdev, linux-kernel

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  5 Mar 2026 12:10:17 +0100 you 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 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.
> 
> [...]

Here is the summary with links:
  - [1/2] nfc: pn533: drop redundant device reference
    https://git.kernel.org/netdev/net-next/c/6c7f71032522
  - [2/2] nfc: port100: drop redundant device reference
    https://git.kernel.org/netdev/net-next/c/1a2d4bfa0491

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-07  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 11:10 [PATCH 0/2] nfc: drop redundant USB device references Johan Hovold
2026-03-05 11:10 ` [PATCH 1/2] nfc: pn533: drop redundant device reference Johan Hovold
2026-03-05 11:10 ` [PATCH 2/2] nfc: port100: " Johan Hovold
2026-03-07  3:10 ` [PATCH 0/2] nfc: drop redundant USB device references patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox