* [PATCH] w1: ds2490: drop redundant device reference
@ 2026-03-05 11:16 Johan Hovold
2026-03-10 20:21 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2026-03-05 11:16 UTC (permalink / raw)
To: Krzysztof Kozlowski; +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/w1/masters/ds2490.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 35e75d07ef5d..aa1f57f74397 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -1022,11 +1022,8 @@ static int ds_probe(struct usb_interface *intf,
if (!dev)
return -ENOMEM;
- dev->udev = usb_get_dev(udev);
- if (!dev->udev) {
- err = -ENOMEM;
- goto err_out_free;
- }
+ dev->udev = udev;
+
memset(dev->ep, 0, sizeof(dev->ep));
usb_set_intfdata(intf, dev);
@@ -1085,9 +1082,8 @@ static int ds_probe(struct usb_interface *intf,
err_out_clear:
usb_set_intfdata(intf, NULL);
- usb_put_dev(dev->udev);
-err_out_free:
kfree(dev);
+
return err;
}
@@ -1107,7 +1103,6 @@ static void ds_disconnect(struct usb_interface *intf)
usb_set_intfdata(intf, NULL);
- usb_put_dev(dev->udev);
kfree(dev);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] w1: ds2490: drop redundant device reference
2026-03-05 11:16 [PATCH] w1: ds2490: drop redundant device reference Johan Hovold
@ 2026-03-10 20:21 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-10 20:21 UTC (permalink / raw)
To: Johan Hovold; +Cc: linux-kernel
On Thu, 05 Mar 2026 12:16:13 +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.
>
> [...]
Applied, thanks!
[1/1] w1: ds2490: drop redundant device reference
https://git.kernel.org/krzk/linux-w1/c/f2c1ae05fe82030537b36012551a5cac28d00254
Best regards,
--
Krzysztof Kozlowski <krzk@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-10 20:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 11:16 [PATCH] w1: ds2490: drop redundant device reference Johan Hovold
2026-03-10 20:21 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox