linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Donnellan <ajd@linux.ibm.com>
To: Yang Yingliang <yangyingliang@huawei.com>, linuxppc-dev@lists.ozlabs.org
Cc: fbarrat@linux.ibm.com, gregkh@linuxfoundation.org, arnd@arndb.de
Subject: Re: [PATCH] misc: ocxl: fix possible name leak in ocxl_file_register_afu()
Date: Mon, 21 Nov 2022 16:52:55 +1100	[thread overview]
Message-ID: <206a399384c9fba8febe5bb7ea4acf644b7f8989.camel@linux.ibm.com> (raw)
In-Reply-To: <20221111145929.2429271-1-yangyingliang@huawei.com>

On Fri, 2022-11-11 at 22:59 +0800, Yang Yingliang wrote:
> If device_register() returns error in ocxl_file_register_afu(),
> the name allocated by dev_set_name() need be freed. As comment
> of device_register() says, it should use put_device() to give
> up the reference in the error path. So fix this by calling
> put_device(), then the name can be freed in kobject_cleanup(),
> and info is freed in info_release().
> 
> Fixes: 75ca758adbaf ("ocxl: Create a clear delineation between ocxl
> backend & frontend")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Thanks for the fix - as you point out, put_device() should clean
everything up that needs cleaning up.

Acked-by: Andrew Donnellan <ajd@linux.ibm.com>

> ---
>  drivers/misc/ocxl/file.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index d46dba2df5a1..452d5777a0e4 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -541,8 +541,11 @@ int ocxl_file_register_afu(struct ocxl_afu *afu)
>                 goto err_put;
>  
>         rc = device_register(&info->dev);
> -       if (rc)
> -               goto err_put;
> +       if (rc) {
> +               free_minor(info);
> +               put_device(&info->dev);
> +               return rc;
> +       }
>  
>         rc = ocxl_sysfs_register_afu(info);
>         if (rc)

-- 
Andrew Donnellan    OzLabs, ADL Canberra
ajd@linux.ibm.com   IBM Australia Limited

  parent reply	other threads:[~2022-11-21  5:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 14:59 [PATCH] misc: ocxl: fix possible name leak in ocxl_file_register_afu() Yang Yingliang
2022-11-14 11:23 ` Frederic Barrat
2022-11-14 11:46   ` Yang Yingliang
2022-11-14 12:04     ` Frederic Barrat
2022-11-21  5:52 ` Andrew Donnellan [this message]
2022-11-30  9:24 ` Michael Ellerman

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=206a399384c9fba8febe5bb7ea4acf644b7f8989.camel@linux.ibm.com \
    --to=ajd@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=fbarrat@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=yangyingliang@huawei.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;
as well as URLs for NNTP newsgroup(s).