Skip to contentSkip to conversation

nfc: drop redundant USB device references

PATCH Applied Johan Hovold 2 participants 4 messages Mar 5 – Mar 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover nfc: drop redundant USB device references

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(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/2 nfc: pn533: 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.

---
 drivers/nfc/pn533/usb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nfc/pn533/usb.c +1 -3
index 0f12f86ebb02..0ff2f0d7caf4 100644
@@ -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");
 }
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/2 nfc: port100: drop redundant device reference

In reply to 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.

---
 drivers/nfc/port100.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nfc/port100.c +1 -3
index a922569d7b48..09dcc6f4c4f3 100644
@@ -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);
 
Signature · 1 line
2.52.0
#3 lore raw
In reply to Johan Hovold
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html