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: <cd20f733-3523-490c-8bc1-73b7300f18b8@fujitsu.com>
Date: Mon, 29 Apr 2024 10:26:47 +0000
From: "Zhijian Li (Fujitsu)" <lizhijian@...itsu.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
CC: "dave@...olabs.net" <dave@...olabs.net>, "jonathan.cameron@...wei.com"
	<jonathan.cameron@...wei.com>, "dave.jiang@...el.com" <dave.jiang@...el.com>,
	"alison.schofield@...el.com" <alison.schofield@...el.com>,
	"vishal.l.verma@...el.com" <vishal.l.verma@...el.com>, "ira.weiny@...el.com"
	<ira.weiny@...el.com>, "dan.j.williams@...el.com" <dan.j.williams@...el.com>,
	"linux-cxl@...r.kernel.org" <linux-cxl@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] cxl/region: Fix missing put_device(region_dev)



On 29/04/2024 18:17, Dan Carpenter wrote:
> On Mon, Apr 29, 2024 at 09:31:54AM +0800, Li Zhijian wrote:
>>>          mutex_lock(&cxlrd->range_lock);
>>>          region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
>>>                                         match_region_by_range);
>>>          if (!region_dev)
>>>                  cxlr = construct_region(cxlrd, cxled);
>>>          else
>>>                  cxlr = to_cxl_region(region_dev);
>>>          mutex_unlock(&cxlrd->range_lock);
>>>
>>>          rc = PTR_ERR_OR_ZERO(cxlr);
>>>          if (rc)
>>>                  goto out;
>>>
>>>          if (!region_dev)
>>>                  region_dev = &cxlr->dev;
>>
>> When to_cxl_region(region_dev) fails,
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> to_cxl_region() will return NULL if "region_dev" is not a region device.
> 
>    2215  static struct cxl_region *to_cxl_region(struct device *dev)
>    2216  {
>    2217          if (dev_WARN_ONCE(dev, dev->type != &cxl_region_type,
>    2218                            "not a cxl_region device\n"))
>    2219                  return NULL;
>    2220
>    2221          return container_of(dev, struct cxl_region, dev);
>    2222  }
> 
> It won't fail.
> 
> If it does fail, we're already in bad shape and it's not worth worrying
> about resource leaks at that point.
> 

Sounds good to me,

Thanks
Zhijian


> regards,
> dan carpenter
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ