Skip to contentSkip to conversation

can: ucan: fix devres lifetime

PATCH New Johan Hovold 1 participant 1 message Mar 27

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

PATCH 1/1 can: ucan: fix devres lifetime

USB drivers bind to USB interfaces and any device managed resources should have their lifetime tied to the interface rather than parent USB device. This avoids issues like memory leaks when drivers are unbound without their devices being physically disconnected (e.g. on probe deferral or configuration changes).

Fix the control message buffer lifetime so that it is released on driver unbind.

Fixes 9f2d3eae88d2 ("can: ucan: add driver for Theobroma Systems UCAN devices")
Cc Jakob Unterwurzacher <[email protected]>
---
 drivers/net/can/usb/ucan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/ucan.c +1 -1
index 0ea0ac75e42f..ee3c1abbd063 100644
@@ -1397,7 +1397,7 @@ static int ucan_probe(struct usb_interface *intf,
 	 */
 
 	/* Prepare Memory for control transfers */
-	ctl_msg_buffer = devm_kzalloc(&udev->dev,
+	ctl_msg_buffer = devm_kzalloc(&intf->dev,
 				      sizeof(union ucan_ctl_payload),
 				      GFP_KERNEL);
 	if (!ctl_msg_buffer) {
Signature · 1 line
2.52.0