[patch] fix: dmi_check_system

From: Robert Love (rml_at_novell.com)
Date: 08/29/05

  • Next message: Andi Kleen: "Re: [patch 08/16] Add support for X86_64 platforms to KGDB"
    To: Mr Morton <akpm@osdl.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
    Date:	Mon, 29 Aug 2005 14:43:15 -0400
    
    

    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

    Signed-off-by: Robert Love <rml@novell.com>

     arch/i386/kernel/dmi_scan.c | 2 +-
     1 files changed, 1 insertion(+), 1 deletion(-)

    diff -urN linux-2.6.13/arch/i386/kernel/dmi_scan.c linux/arch/i386/kernel/dmi_scan.c
    --- linux-2.6.13/arch/i386/kernel/dmi_scan.c 2005-08-29 14:28:33.000000000 -0400
    +++ linux/arch/i386/kernel/dmi_scan.c 2005-08-29 14:35:06.000000000 -0400
    @@ -218,9 +218,9 @@
                             /* No match */
                             goto fail;
                     }
    + count++;
                     if (d->callback && d->callback(d))
                             break;
    - count++;
     fail: d++;
             }
     

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Andi Kleen: "Re: [patch 08/16] Add support for X86_64 platforms to KGDB"

    Relevant Pages

    • [patch 29/29] USB: hidinput_hid_event() oops fix
      ... It seems that I see a bug in hidinput_hid_event. ... becaue &hidinput->input is nonzero at all times. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH] Use after free in drivers/media/video/videodev.c
      ... I think that there's a bug in videdev.c. ... call a ->release callback. ... if a driver switch to dynamically allocated video_device ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Signal left blocked after signal handler.
      ... > Sigsetjmp will save and restore the signal mask ONLY if its second ... > argument is nonzero. ... The libc code is correct. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [ACPI] X86_PM_TIMER: /proc/cpuinfo doesnt get updated
      ... but I think this should do the trick. ... > updated when using the TSC? ... Is cpu_khz always correct (or, at least, nonzero) when we're reaching this ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Bug in BigDecimal#round ?
      ... BigDecimal#round to return nonzero: ... puts "These values appended to '0.0000' cause BigDecimal#round to ... puts "These numbers of zeroes between the decimal point and a 7 cause ... It seems to me as a bug. ...
      (comp.lang.ruby)