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: <Yrlyw1eMFy4kd0JB@google.com>
Date:   Mon, 27 Jun 2022 10:05:07 +0100
From:   Lee Jones <lee.jones@...aro.org>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     linux-kernel@...r.kernel.org, Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v1 01/11] mfd: intel_soc_pmic_bxtwc: Don't shadow error
 codes in show()/store()

On Thu, 16 Jun 2022, Andy Shevchenko wrote:

> kstrtox() along with regmap API can return different error codes based on
> circumstances.
> 
> Don't shadow them when returning to the caller.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  drivers/mfd/intel_soc_pmic_bxtwc.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
> index bc069c4daa60..3148a319d467 100644
> --- a/drivers/mfd/intel_soc_pmic_bxtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
> @@ -339,10 +339,14 @@ static ssize_t addr_show(struct device *dev,
>  static ssize_t addr_store(struct device *dev,
>  			  struct device_attribute *attr, const char *buf, size_t count)
>  {
> -	if (kstrtoul(buf, 0, &bxtwc_reg_addr)) {
> +	int ret;
> +
> +	ret = kstrtoul(buf, 0, &bxtwc_reg_addr);
> +	if (ret) {
>  		dev_err(dev, "Invalid register address\n");

Is that really what failure means, on every failure?

  "Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing
   error."

> -		return -EINVAL;
> +		return ret;
>  	}
> +
>  	return (ssize_t)count;
>  }
>  
> @@ -354,9 +358,9 @@ static ssize_t val_show(struct device *dev,
>  	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
>  
>  	ret = regmap_read(pmic->regmap, bxtwc_reg_addr, &val);
> -	if (ret < 0) {
> +	if (ret) {
>  		dev_err(dev, "Failed to read 0x%lx\n", bxtwc_reg_addr);
> -		return -EIO;
> +		return ret;
>  	}
>  
>  	return sprintf(buf, "0x%02x\n", val);
> @@ -377,7 +381,7 @@ static ssize_t val_store(struct device *dev,
>  	if (ret) {
>  		dev_err(dev, "Failed to write value 0x%02x to address 0x%lx",
>  			val, bxtwc_reg_addr);
> -		return -EIO;
> +		return ret;
>  	}
>  	return count;
>  }

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ