Skip to contentSkip to conversation

usb: ulpi: Use common error handling code in ulpi_register()

PATCH In review Markus Elfring 3 participants 3 messages Jun 8

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

PATCH 1/1 usb: ulpi: Use common error handling code in ulpi_register()

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jun 2026 14:17:57 +0200

Use an additional label so that a bit of exception handling can be better reused at the end of this function implementation.

---
 drivers/usb/common/ulpi.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/common/ulpi.c +7 -6
index 9b69148128e5..1b9a4995903d 100644
@@ -286,16 +286,13 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
 	ACPI_COMPANION_SET(&ulpi->dev, ACPI_COMPANION(dev));
 
 	ret = ulpi_of_register(ulpi);
-	if (ret) {
-		kfree(ulpi);
-		return ret;
-	}
+	if (ret)
+		goto free_ulpi;
 
 	ret = ulpi_read_id(ulpi);
 	if (ret) {
 		of_node_put(ulpi->dev.of_node);
-		kfree(ulpi);
-		return ret;
+		goto free_ulpi;
 	}
 
 	ret = device_register(&ulpi->dev);
@@ -311,6 +308,10 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
 		ulpi->id.vendor, ulpi->id.product);
 
 	return 0;
+
+free_ulpi:
+	kfree(ulpi);
+	return ret;
 }
 
 /**
Signature · 1 line
2.54.0
#1 lore raw
Quoted 7 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jun 2026 14:17:57 +0200

Use an additional label so that a bit of exception handling can be better reused at the end of this function implementation.

This is not a bug fix and clearly not stable material.

Quoted 1 line

A closer look at the code reveals that the device name is still being leaking on errors however (despite the recent flurry of related fixes).

I've just sent a fix here:

	https://lore.kernel.org/r/[email protected]

Johan

#2 lore raw
Quoted 4 lines · Johan Hovold
Quoted 3 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jun 2026 14:17:57 +0200

Quoted 8 lines
Quoted 4 lines

Use an additional label so that a bit of exception handling can be better reused at the end of this function implementation.

This is not a bug fix and clearly not stable material.

Quoted 1 line

Ah, this person's emails go to /dev/null for me, so I've not even considered it, so nothing to worry about :)

thanks,

greg k-h