Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7aa226d authored by Sean Anderson's avatar Sean Anderson Committed by Greg Kroah-Hartman
Browse files

usb: ulpi: Call of_node_put correctly



commit 0a907ee9d95e3ac35eb023d71f29eae0aaa52d1b 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: ef6a7bcf ("usb: ulpi: Support device discovery via DT")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarSean Anderson <sean.anderson@seco.com>
Link: https://lore.kernel.org/r/20220127190004.1446909-3-sean.anderson@seco.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 43951070
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -249,12 +249,16 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
		return ret;
		return ret;


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


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


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