public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Zhi Song <zhi.song@bytedance.com>
Cc: vilhelm.gray@gmail.com, rafael@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] isa: put_device after failing to device_register
Date: Mon, 27 Jun 2022 16:06:11 +0200	[thread overview]
Message-ID: <Yrm5U0wU7tJPhyp6@kroah.com> (raw)
In-Reply-To: <20220615151558.1766067-1-zhi.song@bytedance.com>

On Wed, Jun 15, 2022 at 11:15:58PM +0800, Zhi Song wrote:
> device_register() is used to register a device with the system.
> We need to call put_device() to give up the reference initialized
> in device_register() when it returns an error and this will clean
> up correctly.
> 
> Fixes: a5117ba7da37 ("Driver model: add ISA bus")
> Signed-off-by: Zhi Song <zhi.song@bytedance.com>
> ---
> V1 -> V2: Fix up the changelog text correct.
> V2 -> V3: Add a fixes tag line specifying the commit where this bug was
> introduced.
> ---
>  drivers/base/isa.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/isa.c b/drivers/base/isa.c
> index 55e3ee2da98f..cf88f3d77b7d 100644
> --- a/drivers/base/isa.c
> +++ b/drivers/base/isa.c
> @@ -173,8 +173,10 @@ static int __init isa_bus_init(void)
>  	error = bus_register(&isa_bus_type);
>  	if (!error) {
>  		error = device_register(&isa_bus);
> -		if (error)
> +		if (error) {
> +			put_device(&isa_bus);

Did you test this change and notice the kernel log error that happens
when you run it?

If you can really reproduce this in a real-life situation, you need to
do more than just this change.

thanks,

greg k-h

      parent reply	other threads:[~2022-06-27 14:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 15:15 [PATCH v3] isa: put_device after failing to device_register Zhi Song
2022-06-15 22:03 ` William Breathitt Gray
2022-06-27 14:06 ` Greg KH [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=Yrm5U0wU7tJPhyp6@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=vilhelm.gray@gmail.com \
    --cc=zhi.song@bytedance.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