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] [day] [month] [year] [list]
Message-ID: <Y3tRTTI6nn2JAd+E@smile.fi.intel.com>
Date:   Mon, 21 Nov 2022 12:22:05 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Yang Yingliang <yangyingliang@...wei.com>
Cc:     linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
        djrscally@...il.com, heikki.krogerus@...ux.intel.com,
        sakari.ailus@...ux.intel.com, gregkh@...uxfoundation.org,
        rafael@...nel.org
Subject: Re: [PATCH] device property: fix of node refcount leak in
 fwnode_graph_get_next_endpoint()

On Mon, Nov 21, 2022 at 02:40:49PM +0800, Yang Yingliang wrote:
> The 'parent' returned by fwnode_graph_get_port_parent() with refcount
> incremented when prev is not null, it needs be put when finish using
> it.

...

>  	ep = fwnode_call_ptr_op(parent, graph_get_next_endpoint, prev);
> -	if (ep)
> +	if (ep) {
> +		if (prev)
> +			fwnode_handle_put((struct fwnode_handle *)parent);

Instead of castings, drop the const qualifier in the definition block.

>  		return ep;
> +	}

But, the point is that this is a very tricky code and your commit message
lacks of analysis. Can you extend it and show that every case is covered
correctly?

> -	return fwnode_graph_get_next_endpoint(parent->secondary, NULL);
> +	ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL);
> +	if (prev)

Instead you might consider to replace

	parent = fwnode;

by

	parent = fwnode_handle_get(fwnode);

but please double check that each branch has proper reference counting.

> +		fwnode_handle_put((struct fwnode_handle *)parent);
> +	return ep;

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ