Skip to content

Commit 0a907ee

Browse files
sean-anderson-secogregkh
authored andcommitted
usb: ulpi: Call of_node_put correctly
of_node_put should always be called on device nodes gotten from of_get_*. Additionally, it should only be called after there are no remaining users. To address the first issue, call of_node_put if later steps in ulpi_register fail. To address the latter, call put_device if device_register fails, which will call ulpi_dev_release if necessary. Fixes: ef6a7bc ("usb: ulpi: Support device discovery via DT") Cc: stable <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Sean Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 092f45b commit 0a907ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/usb/common/ulpi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,16 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
248248
return ret;
249249

250250
ret = ulpi_read_id(ulpi);
251-
if (ret)
251+
if (ret) {
252+
of_node_put(ulpi->dev.of_node);
252253
return ret;
254+
}
253255

254256
ret = device_register(&ulpi->dev);
255-
if (ret)
257+
if (ret) {
258+
put_device(&ulpi->dev);
256259
return ret;
260+
}
257261

258262
dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n",
259263
ulpi->id.vendor, ulpi->id.product);

0 commit comments

Comments
 (0)