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] [day] [month] [year] [list]
Date:	Wed, 27 May 2015 10:55:06 +0200
From:	Alexandre Belloni <alexandre.belloni@...e-electrons.com>
To:	Jan Kardell <jan.kardell@...liq.com>
Cc:	Alessandro Zummo <a.zummo@...ertech.it>,
	rtc-linux@...glegroups.com, linux-kernel@...r.kernel.org,
	Vincent Donnefort <vdonnefort@...il.com>,
	Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH] rtc: pcf8563 fix: return -EINVAL if we read an invalid
 time.

Hi,

On 25/05/2015 at 11:51:14 +0200, Jan Kardell wrote :
> @@ -202,8 +202,9 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
>  
>  	if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) {
>  		pcf8563->voltage_low = 1;
> -		dev_info(&client->dev,
> +		dev_err(&client->dev,
>  			"low voltage detected, date/time is not reliable.\n");
> +		return -EINVAL;
>  	}
>  
>  	dev_dbg(&client->dev,
> @@ -234,11 +235,11 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
>  		tm->tm_sec, tm->tm_min, tm->tm_hour,
>  		tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
>  
> -	/* the clock can give out invalid datetime, but we cannot return
> -	 * -EINVAL otherwise hwclock will refuse to set the time on bootup.
> -	 */
> -	if (rtc_valid_tm(tm) < 0)
> +	err = rtc_valid_tm(tm);
> +	if (err < 0) {
>  		dev_err(&client->dev, "retrieved date/time is not valid.\n");
> +		return err;
> +	}

I would avoid dev_err and directly return rtc_valid_tm(tm) or you could
also return 0 and let the core do the rtc_valid_tm() check.

>  
>  	return 0;
>  }
> -- 
> 1.8.4.5
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ