public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>
Subject: [PATCH] w1: ds2490: drop redundant device reference
Date: Fri,  3 Apr 2026 10:44:51 +0200	[thread overview]
Message-ID: <20260403084450.6314-2-krzk@kernel.org> (raw)

From: Johan Hovold <johan@kernel.org>

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>
Link: https://patch.msgid.link/20260305111613.18546-1-johan@kernel.org
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---

Hi Greg,

I have only one patch in w1 drivers queue. It was sitting in linux-next
for three weeks, but I will drop it now from for-next branch, to avoid
duplicated patches warning from Mark.

BR,
Krzysztof

 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.51.0


             reply	other threads:[~2026-04-03  8:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03  8:44 Krzysztof Kozlowski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-03-05 11:16 [PATCH] w1: ds2490: drop redundant device reference Johan Hovold
2026-03-10 20:21 ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260403084450.6314-2-krzk@kernel.org \
    --to=krzk@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox