Skip to contentSkip to conversation

fix: dmi_check_system

PATCH New Robert Love 1 participant 1 message Aug 29, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix: dmi_check_system

Background:

1) dmi_check_system() returns the count of the number of matches. Zero thus means no matches.
2) A match callback can return nonzero to stop the match checking.

Bug: The count is incremented after we check for the nonzero return value, so it does not reflect the actual count. We could say this is intended, for some dumb reason, except that it means that a match on the first check returns zero--no matches--if the callback returns nonzero.

Attached patch implements the count before calling the callback and thus before potentially short-circuiting.

Robert Love

 arch/i386/kernel/dmi_scan.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/i386/kernel/dmi_scan.c +1 -1
diff -urN linux-2.6.13/arch/i386/kernel/dmi_scan.c linux/arch/i386/kernel/dmi_scan.c
@@ -218,9 +218,9 @@
 			/* No match */
 			goto fail;
 		}
+		count++;
 		if (d->callback && d->callback(d))
 			break;
-		count++;
 fail:		d++;
 	}