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]
Date:	Sat, 28 Feb 2015 13:22:54 -0800
From:	Joe Perches <joe@...ches.com>
To:	Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Cc:	Alessandro Zummo <a.zummo@...ertech.it>,
	linux-kernel@...r.kernel.org, rtc-linux@...glegroups.com
Subject: Re: [PATCH] rtc: add Abracon ABx80x driver

On Sat, 2015-02-28 at 21:52 +0100, Alexandre Belloni wrote:
> > > diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> > []
> > > +static int ab08xx_get_datetime(struct i2c_client *client, struct rtc_time *tm)
[]
> > > +	tm->tm_sec = bcd2bin(date[AB08XX_REG_SC] & 0x7F);
> > > +	tm->tm_min = bcd2bin(date[AB08XX_REG_MN] & 0x7F);
> > > +	tm->tm_hour = bcd2bin(date[AB08XX_REG_HR] & 0x3F);
> > > +	tm->tm_wday = date[AB08XX_REG_WD] & 0x7;
> > > +	tm->tm_mday = bcd2bin(date[AB08XX_REG_DA] & 0x3F);
> > > +	tm->tm_mon = bcd2bin(date[AB08XX_REG_MO] & 0x1F) - 1;
> > > +	tm->tm_year = bcd2bin(date[AB08XX_REG_YR]);
> > > +	if (tm->tm_year < 70)
> > > +		tm->tm_year += 100;
> > > +
> > > +	err = rtc_valid_tm(tm);
> > > +	if (err < 0)
> > > +		dev_err(&client->dev, "retrieved date/time is not valid.\n");
> > 
> > Is setting the date to a known bad value really the desired thing?
> 
> I'm not sure what you mean here, isn't that what is done in almost all
> the rtc drivers?

Dunno.

> A lot of those are simply using return
> rtc_valid_tm(tm); My guess is that a userspace program must not try to
> use tm when errno is not 0.

My thought was that it might be better to
use a local struct rtc_time r like

	r.tm_sec = bcd2bin(date[AB08XX_REG_SC] & 0x7F);
	r.tm_min = bcd2bin(date[AB08XX_REG_MN] & 0x7F);
	r.tm_hour = bcd2bin(date[AB08XX_REG_HR] & 0x3F);
	r.tm_wday = date[AB08XX_REG_WD] & 0x7;
	r.tm_mday = bcd2bin(date[AB08XX_REG_DA] & 0x3F);
	r.tm_mon = bcd2bin(date[AB08XX_REG_MO] & 0x1F) - 1;
	r.tm_year = bcd2bin(date[AB08XX_REG_YR]);
	if (r.tm_year < 70)
		r.tm_year += 100;

	err = rtc_valid_tm(&r);
	if (!err)
		*tm = r;
	else
		dev_err(&client->dev, "retrieved date/time is not valid\n");

	return err;


--
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