From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Sean Anderson <sean.anderson@seco.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] usb: ulpi: Call of_node_put correctly
Date: Tue, 25 Jan 2022 11:18:09 +0200 [thread overview]
Message-ID: <Ye/AUUlnuHBoGxab@kuha.fi.intel.com> (raw)
In-Reply-To: <20220124173344.874885-2-sean.anderson@seco.com>
On Mon, Jan 24, 2022 at 12:33:44PM -0500, Sean Anderson wrote:
> 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 of_node_put
> only after calling device_unregister.
This looks like a fix, but you don't have the fix tag.
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> Changes in v2:
> - New
>
> drivers/usb/common/ulpi.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
> index 87deb514eb78..c6ba72544f2b 100644
> --- a/drivers/usb/common/ulpi.c
> +++ b/drivers/usb/common/ulpi.c
> @@ -301,11 +301,11 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
>
> ret = ulpi_read_id(ulpi);
> if (ret)
> - return ret;
> + goto err;
>
> ret = device_register(&ulpi->dev);
> if (ret)
> - return ret;
> + goto err;
I think there is another bug in the code here. Missing put_device().
If you first fix that, you should then be able to call
fwnode_handle_put() (instead of of_node_put()) from
ulpi_dev_release(), and that should cover all cases.
> root = debugfs_create_dir(dev_name(dev), ULPI_ROOT);
> debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_ops);
> @@ -314,6 +314,10 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
> ulpi->id.vendor, ulpi->id.product);
>
> return 0;
> +
> +err:
> + of_node_put(ulpi->dev.of_node);
> + return ret;
So no need for that.
> }
>
> /**
> @@ -357,8 +361,8 @@ void ulpi_unregister_interface(struct ulpi *ulpi)
> {
> debugfs_remove_recursive(debugfs_lookup(dev_name(&ulpi->dev),
> ULPI_ROOT));
> - of_node_put(ulpi->dev.of_node);
> device_unregister(&ulpi->dev);
> + of_node_put(ulpi->dev.of_node);
> }
And here you can just remove that of_node_put() call.
thanks,
--
heikki
next prev parent reply other threads:[~2022-01-25 9:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 17:33 [PATCH v2 1/2] usb: ulpi: Add debugfs support Sean Anderson
2022-01-24 17:33 ` [PATCH v2 2/2] usb: ulpi: Call of_node_put correctly Sean Anderson
2022-01-25 9:18 ` Heikki Krogerus [this message]
2022-01-25 16:53 ` Sean Anderson
2022-01-25 17:01 ` Sean Anderson
2022-01-26 13:04 ` Greg Kroah-Hartman
2022-01-27 16:25 ` Sean Anderson
2022-01-26 13:37 ` Heikki Krogerus
2022-01-26 13:05 ` [PATCH v2 1/2] usb: ulpi: Add debugfs support Greg Kroah-Hartman
2022-01-27 16:31 ` Sean Anderson
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=Ye/AUUlnuHBoGxab@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sean.anderson@seco.com \
/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®