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: <681e2d7d4e63e_27eca02942@dwillia2-xfh.jf.intel.com.notmuch>
Date: Fri, 9 May 2025 09:29:49 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Robert Richter <rrichter@....com>, Alison Schofield
	<alison.schofield@...el.com>, Vishal Verma <vishal.l.verma@...el.com>, "Ira
 Weiny" <ira.weiny@...el.com>, Dan Williams <dan.j.williams@...el.com>,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>, Dave Jiang
	<dave.jiang@...el.com>, Davidlohr Bueso <dave@...olabs.net>
CC: <linux-cxl@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Gregory Price
	<gourry@...rry.net>, "Fabio M. De Francesco"
	<fabio.m.de.francesco@...ux.intel.com>, Terry Bowman <terry.bowman@....com>,
	Robert Richter <rrichter@....com>
Subject: Re: [PATCH v6 10/14] cxl/region: Factor out code to find a root
 decoder's region

Robert Richter wrote:
> In function cxl_add_to_region() there is code to determine a root
> decoder's region. Factor that code out. This is in preparation to
> further rework and simplify function cxl_add_to_region().
> 
> The reference count must be decremented after using the region.
> cxl_find_region_by_range() is paired with the put_cxl_region cleanup
> helper that can be used for this.
> 
> Signed-off-by: Robert Richter <rrichter@....com>
> Reviewed-by: Gregory Price <gourry@...rry.net>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> Reviewed-by: Dave Jiang <dave.jiang@...el.com>
> Reviewed-by: Dan Williams <dan.j.williams@...el.com>
> Reviewed-by: Alison Schofield <alison.schofield@...el.com>
> Reviewed-by: Fabio M. De Francesco <fabio.m.de.francesco@...ux.intel.com>
> Tested-by: Gregory Price <gourry@...rry.net>
> ---
>  drivers/cxl/core/region.c | 26 ++++++++++++++++----------
>  drivers/cxl/cxl.h         |  1 +
>  2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 45f5d2c7dfdf..8fdf03058b2f 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -3405,13 +3405,25 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
>  	return cxlr;
>  }
>  
> +static struct cxl_region *
> +cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa)
> +{
> +	struct device *region_dev;
> +
> +	region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
> +				       match_region_by_range);
> +	if (!region_dev)
> +		return NULL;
> +
> +	return to_cxl_region(region_dev);
> +}
> +
>  int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
>  {
>  	struct cxl_root_decoder *cxlrd __free(put_cxl_root_decoder) = NULL;
> +	struct cxl_region *cxlr __free(put_cxl_region) = NULL;

Another instance of the "obj __free(...) = NULL" anti-pattern to clean
up. The reason it is an anti-pattern is because it risks mixing up the
assignment order with the declaration order leading to subtle bugs.

Scope-based cleanup should always be exempted from "x-mas" tree
declaration cosmetics.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ