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: <ec04b92f-e916-4769-be82-93f369c9c593@intel.com>
Date: Wed, 19 Feb 2025 10:16:22 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Li Ming <ming.li@...omail.com>, dave@...olabs.net,
 jonathan.cameron@...wei.com, alison.schofield@...el.com,
 vishal.l.verma@...el.com, ira.weiny@...el.com, dan.j.williams@...el.com
Cc: linux-cxl@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/7] cxl/memdev: cxl_memdev_ioctl() cleanup



On 2/17/25 7:48 AM, Li Ming wrote:
> In cxl_memdev_ioctl(), the down_read(&cxl_memdev_rwsem) and
> up_read(&cxl_memdev_rwsem) can be replaced by a
> guard(rwsem_read)(&cxl_memdev_rwsem), it helps to remove the open-coded
> up_read(&cxl_memdev_rwsem). Besides, the local var 'rc' can be also
> removed to make the code more cleaner.
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> Signed-off-by: Li Ming <ming.li@...omail.com>
Reviewed-by: Dave Jiang <dave.jiang@...el.com>

> ---
>  drivers/cxl/core/memdev.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index 98c05426aa4a..6f90dcd626f9 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -668,15 +668,13 @@ static long cxl_memdev_ioctl(struct file *file, unsigned int cmd,
>  {
>  	struct cxl_memdev *cxlmd = file->private_data;
>  	struct cxl_dev_state *cxlds;
> -	int rc = -ENXIO;
>  
> -	down_read(&cxl_memdev_rwsem);
> +	guard(rwsem_read)(&cxl_memdev_rwsem);
>  	cxlds = cxlmd->cxlds;
>  	if (cxlds && cxlds->type == CXL_DEVTYPE_CLASSMEM)
> -		rc = __cxl_memdev_ioctl(cxlmd, cmd, arg);
> -	up_read(&cxl_memdev_rwsem);
> +		return __cxl_memdev_ioctl(cxlmd, cmd, arg);
>  
> -	return rc;
> +	return -ENXIO;
>  }
>  
>  static int cxl_memdev_open(struct inode *inode, struct file *file)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ