lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87o82pomrc.fsf@mpe.ellerman.id.au>
Date:   Tue, 01 Mar 2022 23:55:35 +1100
From:   Michael Ellerman <mpe@...erman.id.au>
To:     Hangyu Hua <hbh25y@...il.com>, benh@...nel.crashing.org,
        paulus@...ba.org
Cc:     linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        Hangyu Hua <hbh25y@...il.com>
Subject: Re: [PATCH] powerpc: kernel: fix a refcount leak in format_show()

Hangyu Hua <hbh25y@...il.com> writes:
> node needs to be dropped when of_property_read_string fails. So an earlier call
> to of_node_put is required here.

That's true but ...

> diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
> index a0a78aba2083..cd0fa7028d86 100644
> --- a/arch/powerpc/kernel/secvar-sysfs.c
> +++ b/arch/powerpc/kernel/secvar-sysfs.c
> @@ -30,13 +30,12 @@ static ssize_t format_show(struct kobject *kobj, struct kobj_attribute *attr,
>  		return -ENODEV;

There's also a reference leak there ^

So if you're going to touch this code I'd like you to fix both reference
leaks in a single patch please.

Having the error cases set rc and then goto "out" which does the
of_node_put() is the obvious solution I think.

cheers

>  	rc = of_property_read_string(node, "format", &format);
> +	of_node_put(node);
>  	if (rc)
>  		return rc;
>  
>  	rc = sprintf(buf, "%s\n", format);
>  
> -	of_node_put(node);
> -
>  	return rc;
>  }
>  
> -- 
> 2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ