Skip to content

Commit

Permalink
usb: ulpi: Call of_node_put correctly
Browse files Browse the repository at this point in the history
commit 0a907ee upstream.

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 <stable@vger.kernel.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Link: https://lore.kernel.org/r/20220127190004.1446909-3-sean.anderson@seco.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
sean-anderson-seco authored and gregkh committed Feb 16, 2022
1 parent 5751b4a commit e0b2f29
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/usb/common/ulpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,16 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
return ret;

ret = ulpi_read_id(ulpi);
if (ret)
if (ret) {
of_node_put(ulpi->dev.of_node);
return ret;
}

ret = device_register(&ulpi->dev);
if (ret)
if (ret) {
put_device(&ulpi->dev);
return ret;
}

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

0 comments on commit e0b2f29

Please sign in to comment.