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: <87skwvcl2a.fsf@duaron.myhome.or.jp>
Date:	Wed, 07 May 2008 04:02:53 +0900
From:	OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Yinghai Lu <yhlu.kernel@...il.com>, Greg KH <gregkh@...e.de>,
	Ingo Molnar <mingo@...e.hu>, Len Brown <lenb@...nel.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@...r.kernel.org>,
	linux-acpi <linux-acpi@...r.kernel.org>
Subject: Re: acpi_cpu_freq_init warning...

Linus Torvalds <torvalds@...ux-foundation.org> writes:

> On Tue, 6 May 2008, OGAWA Hirofumi wrote:
>> -	if ((drv->entry.next != drv->entry.prev) ||
>> +	if ((drv->entry.next != drv->entry.prev) &&
>>  	    (drv->entry.next != NULL)) {
>
> Umm. That code still makes no sense.
>
> The "drv->entry.next == drv->entry.prev" condition will trigger under 
> *three* different circumstances:
>
>  - next/prev == NULL (uninitialized). Checked for by the explicit check 
>    against NULL.
>
>  - list empty (both next/prev point back to itself), which I assume the 
>    check was *meant* for.
>
>  - list has only *one* entry, when next/prev both point to the list head.
>
> and I'm pretty damn sure that whoever wrote that code didn't mean that 
> last one, but who knows..
>
> The fact is, looking at next/prev this way is a sure way to have bugs.
>
> What is that PoS *trying* to test for? I assume it is meant to test for
>
> 	/* Is the list initialized and non-empty? */
> 	if (drv->entry.next && !list_empty(&drv->entry)) {
> 		...
>
> and dammit, just doing it that way is shorter and simpler.

Whoops, sorry. You are right.

diff -puN drivers/base/sys.c~fix-sys-bogus-warning drivers/base/sys.c
--- linux-2.6/drivers/base/sys.c~fix-sys-bogus-warning	2008-05-07 03:51:00.000000000 +0900
+++ linux-2.6-hirofumi/drivers/base/sys.c	2008-05-07 04:01:14.000000000 +0900
@@ -175,8 +175,7 @@ int sysdev_driver_register(struct sysdev
 	}
 
 	/* Check whether this driver has already been added to a class. */
-	if ((drv->entry.next != drv->entry.prev) ||
-	    (drv->entry.next != NULL)) {
+	if (drv->entry.next && !list_empty(&drv->entry)) {
 		printk(KERN_WARNING "sysdev: class %s: driver (%p) has already"
 			" been registered to a class, something is wrong, but "
 			"will forge on!\n", cls->name, drv);
_
-- 
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
--
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