From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafał Miłecki" <zajec5@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] driver core: platform: document registration-failure requirement
Date: Wed, 22 Dec 2021 10:55:54 +0100 [thread overview]
Message-ID: <YcL2KpAFPOuWYlei@hovoldconsulting.com> (raw)
In-Reply-To: <20211222085229.11657-1-johan@kernel.org>
On Wed, Dec 22, 2021 at 09:52:29AM +0100, Johan Hovold wrote:
> Add an explicit comment to document that the reference initialised by
> platform_device_register() needs to be released by a call to
> platform_device_put() also when registration fails (cf.
> device_register()).
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/base/platform.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 598acf93a360..38fdcbdba4a4 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -762,6 +762,10 @@ EXPORT_SYMBOL_GPL(platform_device_del);
> /**
> * platform_device_register - add a platform-level device
> * @pdev: platform device we're adding
> + *
> + * NOTE: _Never_ directly free @pdev after calling this function, even if it
> + * returned an error! Always use platform_put_device() to give up the
This should have been platform_device_put().
Greg, I'll send a v2 for you to consider since this documents the
current behaviour even if you wanted to look into ways to change this.
> + * reference initialised in this function instead.
> */
> int platform_device_register(struct platform_device *pdev)
> {
Johan
prev parent reply other threads:[~2021-12-22 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 8:52 [PATCH] driver core: platform: document registration-failure requirement Johan Hovold
2021-12-22 9:55 ` Johan Hovold [this message]
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=YcL2KpAFPOuWYlei@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zajec5@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.