From: Sean Anderson <sean.anderson@seco.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
linux-kernel@vger.kernel.org,
Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH v3 2/3] usb: ulpi: Call of_node_put correctly
Date: Thu, 27 Jan 2022 14:00:03 -0500 [thread overview]
Message-ID: <20220127190004.1446909-3-sean.anderson@seco.com> (raw)
In-Reply-To: <20220127190004.1446909-1-sean.anderson@seco.com>
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: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
Changes in v3:
- Add Fixes tag
- Call put_device if device_register fails
Changes in v2:
- New
drivers/usb/common/ulpi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index c90a1ab705a3..dedcb749a02f 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -245,12 +245,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);
--
2.25.1
next prev parent reply other threads:[~2022-01-27 19:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 19:00 [PATCH v3 0/3] usb: ulpi: Fixes and debugfs support Sean Anderson
2022-01-27 19:00 ` [PATCH v3 1/3] usb: ulpi: Move of_node_put to ulpi_dev_release Sean Anderson
2022-01-31 11:07 ` Heikki Krogerus
2022-01-27 19:00 ` Sean Anderson [this message]
2022-01-31 11:08 ` [PATCH v3 2/3] usb: ulpi: Call of_node_put correctly Heikki Krogerus
2022-01-27 19:00 ` [PATCH v3 3/3] usb: ulpi: Add debugfs support Sean Anderson
2022-01-31 11:10 ` Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220127190004.1446909-3-sean.anderson@seco.com \
--to=sean.anderson@seco.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®