All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangyu Hua <hbh25y@gmail.com>
To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org,
	tyreld@linux.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] powerpc: kernel: fix refcount leak in format_show()
Date: Mon, 7 Mar 2022 10:52:25 +0800	[thread overview]
Message-ID: <a044e19d-4996-ab16-785f-e8e87e6c05a8@gmail.com> (raw)
In-Reply-To: <20220302021959.10959-1-hbh25y@gmail.com>

Any further suggestions for this patch? guys.

Thanks.

On 2022/3/2 10:19, Hangyu Hua wrote:
> Refcount leak will happen when format_show returns failure in multiple
> cases. Unified management of of_node_put can fix this problem.
> 
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
> 
> v2:
> 1. change the title and description information.
> 2. fix all possible refcount leak.
> 
>   arch/powerpc/kernel/secvar-sysfs.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
> index a0a78aba2083..1ee4640a2641 100644
> --- a/arch/powerpc/kernel/secvar-sysfs.c
> +++ b/arch/powerpc/kernel/secvar-sysfs.c
> @@ -26,15 +26,18 @@ static ssize_t format_show(struct kobject *kobj, struct kobj_attribute *attr,
>   	const char *format;
>   
>   	node = of_find_compatible_node(NULL, NULL, "ibm,secvar-backend");
> -	if (!of_device_is_available(node))
> -		return -ENODEV;
> +	if (!of_device_is_available(node)) {
> +		rc = -ENODEV;
> +		goto out;
> +	}
>   
>   	rc = of_property_read_string(node, "format", &format);
>   	if (rc)
> -		return rc;
> +		goto out;
>   
>   	rc = sprintf(buf, "%s\n", format);
>   
> +out:
>   	of_node_put(node);
>   
>   	return rc;

  reply	other threads:[~2022-03-07  2:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02  2:19 [PATCH v2] powerpc: kernel: fix refcount leak in format_show() Hangyu Hua
2022-03-07  2:52 ` Hangyu Hua [this message]
2022-03-12 10:29 ` 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=a044e19d-4996-ab16-785f-e8e87e6c05a8@gmail.com \
    --to=hbh25y@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=tyreld@linux.ibm.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.