From: Robert Love Date: Tue, 6 Sep 2005 22:18:30 +0000 (-0700) Subject: [PATCH] fix: dmi_check_system X-Git-Tag: v2.6.14-rc1~620 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=640e803376b9c4072f69fec42e304c974a631298;p=linux-2.6 [PATCH] 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. Signed-off-by: Robert Love Cc: Andrey Panin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c index c4a73855e3..58516e2ac1 100644 --- a/arch/i386/kernel/dmi_scan.c +++ b/arch/i386/kernel/dmi_scan.c @@ -248,9 +248,9 @@ int dmi_check_system(struct dmi_system_id *list) /* No match */ goto fail; } + count++; if (d->callback && d->callback(d)) break; - count++; fail: d++; }