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:	Thu, 07 Dec 2006 13:08:00 +0000
From:	David Howells <dhowells@...hat.com>
To:	Al Viro <viro@....linux.org.uk>, mgreer@...sta.com
Cc:	Linus Torvalds <torvalds@...l.org>, dhowells@...hat.com,
	linux-kernel@...r.kernel.org
Subject: Re: ... and more... 

Al Viro <viro@....linux.org.uk> wrote:

> diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c

This could be done differently.  m41t00_set() is only called on that global
variable, so why pass its address in as an argument?

The old code is also wrong: m41t00_set() was being passed a pointer to an
unsigned long, but then was casting it to a pointer to an int before
dereferencing it.  This works on a 32-bit platform, but it's just asking for
trouble on a 64-bit big-endian platform.  However, the driver can only be
configured when CONFIG_PPC32=y, so it will have gone unnoticed.

David
---
Fix m41t00_set() and its usage with workqueues

From: David Howells <dhowells@...hat.com>

Fix m41t00_set() and its usage with workqueues.  It doesn't really need an
argument since it always affects the same global variable.

Signed-Off-By: David Howells <dhowells@...hat.com>
---

 drivers/i2c/chips/m41t00.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 420377c..98978ab 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -165,11 +165,13 @@ read_err:
 }
 EXPORT_SYMBOL_GPL(m41t00_get_rtc_time);
 
+static ulong new_time;
+
 static void
-m41t00_set(void *arg)
+m41t00_set(struct work_struct *unused)
 {
 	struct rtc_time	tm;
-	int nowtime = *(int *)arg;
+	int nowtime = new_time;
 	s32 sec, min, hour, day, mon, year;
 	u8 wbuf[9], *buf = &wbuf[1], msgbuf[1] = { 0 };
 	struct i2c_msg msgs[] = {
@@ -214,16 +216,8 @@ m41t00_set(void *arg)
 		dev_err(&save_client->dev, "m41t00_set: Write error\n");
 }
 
-static ulong new_time;
-/* well, isn't this API just _lovely_? */
-static void
-m41t00_barf(struct work_struct *unusable)
-{
-	m41t00_set(&new_time);
-}
-
 static struct workqueue_struct *m41t00_wq;
-static DECLARE_WORK(m41t00_work, m41t00_barf);
+static DECLARE_WORK(m41t00_work, m41t00_set);
 
 int
 m41t00_set_rtc_time(ulong nowtime)
@@ -233,7 +227,7 @@ m41t00_set_rtc_time(ulong nowtime)
 	if (in_interrupt())
 		queue_work(m41t00_wq, &m41t00_work);
 	else
-		m41t00_set(&new_time);
+		m41t00_set(NULL);
 
 	return 0;
 }
-
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