public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* rtc-ds1307.c: array overrun
@ 2007-07-23  0:44 Adrian Bunk
  2007-07-23  1:17 ` David Brownell
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Bunk @ 2007-07-23  0:44 UTC (permalink / raw)
  To: Rodolfo Giometti, David Brownell, a.zummo; +Cc: rtc-linux, linux-kernel

The Coverity checker spotted the following array overrun
in drivers/rtc/rtc-ds1307.c:

<--  snip  -->

...
#define DS1337_REG_CONTROL      0x0e
...
struct ds1307 {
        u8                      reg_addr;
        u8                      regs[8];
...
};
...
static int __devinit ds1307_probe(struct i2c_client *client)
{
...
                                        ds1307->regs[DS1337_REG_CONTROL]
...

<--  snip  -->


0x0e > 8


cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rtc-ds1307.c: array overrun
  2007-07-23  0:44 rtc-ds1307.c: array overrun Adrian Bunk
@ 2007-07-23  1:17 ` David Brownell
  2007-07-25  1:37   ` [rtc-linux] " Alessandro Zummo
  0 siblings, 1 reply; 3+ messages in thread
From: David Brownell @ 2007-07-23  1:17 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Rodolfo Giometti, a.zummo, rtc-linux, linux-kernel

On Sunday 22 July 2007, Adrian Bunk wrote:
> The Coverity checker spotted the following array overrun
> in drivers/rtc/rtc-ds1307.c:

Typo -- thanks, fix is attached.

========	CUT HERE
Fix a typo turned up by a Coverity check:  referring to the wrong register,
which could cause problems restarting DS1338 RTCs after their oscillator
halted.  (For example, if the backup battery died.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 drivers/rtc/rtc-ds1307.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- g26.orig/drivers/rtc/rtc-ds1307.c	2007-07-22 18:10:09.000000000 -0700
+++ g26/drivers/rtc/rtc-ds1307.c	2007-07-22 18:10:21.000000000 -0700
@@ -352,7 +352,7 @@ read_rtc:
 		/* oscillator fault?  clear flag, and warn */
 		if (ds1307->regs[DS1307_REG_CONTROL] & DS1338_BIT_OSF) {
 			i2c_smbus_write_byte_data(client, DS1307_REG_CONTROL,
-					ds1307->regs[DS1337_REG_CONTROL]
+					ds1307->regs[DS1307_REG_CONTROL]
 					& ~DS1338_BIT_OSF);
 			dev_warn(&client->dev, "SET TIME!\n");
 			goto read_rtc;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [rtc-linux] Re: rtc-ds1307.c: array overrun
  2007-07-23  1:17 ` David Brownell
@ 2007-07-25  1:37   ` Alessandro Zummo
  0 siblings, 0 replies; 3+ messages in thread
From: Alessandro Zummo @ 2007-07-25  1:37 UTC (permalink / raw)
  To: rtc-linux; +Cc: david-b, Adrian Bunk, Rodolfo Giometti, linux-kernel, akpm

On Sun, 22 Jul 2007 18:17:17 -0700
David Brownell <david-b@pacbell.net> wrote:

> 
> On Sunday 22 July 2007, Adrian Bunk wrote:
> > The Coverity checker spotted the following array overrun
> > in drivers/rtc/rtc-ds1307.c:
> 
> Typo -- thanks, fix is attached.
> 
> ========	CUT HERE
> Fix a typo turned up by a Coverity check:  referring to the wrong register,
> which could cause problems restarting DS1338 RTCs after their oscillator
> halted.  (For example, if the backup battery died.)
> 
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

 
 Acked-by: Alessandro Zummo <a.zummo@towertech.it>

-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-25  1:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23  0:44 rtc-ds1307.c: array overrun Adrian Bunk
2007-07-23  1:17 ` David Brownell
2007-07-25  1:37   ` [rtc-linux] " Alessandro Zummo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox