Commit 94e731cb authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

w1: ds2490: 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.

Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260305111613.18546-1-johan@kernel.org


Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Link: https://patch.msgid.link/20260403084450.6314-2-krzk@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a1ed2cbb
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -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);
}