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: <8f5f10be-333a-9d88-7acf-1cbb2b11680@linux.intel.com>
Date:   Fri, 25 Aug 2023 11:09:14 +0300 (EEST)
From:   Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To:     Bjorn Helgaas <helgaas@...nel.org>
cc:     linux-pci@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH 12/12] PCI: Simplify pcie_capability_clear_and_set_word()
 control flow

On Thu, 24 Aug 2023, Bjorn Helgaas wrote:

> From: Bjorn Helgaas <bhelgaas@...gle.com>
> 
> Return early for errors in pcie_capability_clear_and_set_word_unlocked()
> and pcie_capability_clear_and_set_dword() to simplify the control flow.
> 
> No functional change intended.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@...gle.com>
> Cc: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>

-- 
 i.

> ---
>  drivers/pci/access.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> index 0b2e90d2f04f..6554a2e89d36 100644
> --- a/drivers/pci/access.c
> +++ b/drivers/pci/access.c
> @@ -504,13 +504,12 @@ int pcie_capability_clear_and_set_word_unlocked(struct pci_dev *dev, int pos,
>  	u16 val;
>  
>  	ret = pcie_capability_read_word(dev, pos, &val);
> -	if (!ret) {
> -		val &= ~clear;
> -		val |= set;
> -		ret = pcie_capability_write_word(dev, pos, val);
> -	}
> +	if (ret)
> +		return ret;
>  
> -	return ret;
> +	val &= ~clear;
> +	val |= set;
> +	return pcie_capability_write_word(dev, pos, val);
>  }
>  EXPORT_SYMBOL(pcie_capability_clear_and_set_word_unlocked);
>  
> @@ -535,13 +534,12 @@ int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
>  	u32 val;
>  
>  	ret = pcie_capability_read_dword(dev, pos, &val);
> -	if (!ret) {
> -		val &= ~clear;
> -		val |= set;
> -		ret = pcie_capability_write_dword(dev, pos, val);
> -	}
> +	if (ret)
> +		return ret;
>  
> -	return ret;
> +	val &= ~clear;
> +	val |= set;
> +	return pcie_capability_write_dword(dev, pos, val);
>  }
>  EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
>  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ