WDK 6001: PREfast bug

Discussion in 'Windows Vista Drivers' started by Maxim S. Shatskih, Mar 14, 2008.

  1. Here is it. KeReleaseSpinLock was added temporarily to try to get rid of
    PREfast warning. Unfortunately, this does not help, and a valid sequence of 2
    MS's functions causes a warning:

    // !!!
    713 KeReleaseSpinLock(&(Disk->SpinLock), Irql);
    714 IoCompleteRequest(Irp, IO_NO_INCREMENT);

    vsnap.c(714) : warning 28192: No resource of the class 'SpinLock'
    can be held when this function is called. 'Disk->SpinLock' is currently held.
    Maxim S. Shatskih, Mar 14, 2008
    1. Advertisements

  2. Maxim S. Shatskih

    0dbell Guest

    If you know that the PREfast warning is false positive, why do you add
    code that actually effects execution?

    I would think that using a Nonmemory Resource Annotation is
    preferrable in such case. For example, can you use
    __drv_releasesResource or __drv_releasesResourceGlobal here?


    Unless, of course, I misunderstood what you wrote.

    0dbell, Mar 14, 2008
    1. Advertisements

  3. If you know that the PREfast warning is false positive, why do you add
    KeReleaseSpinLock marked by !!! was _surely_ never intended to be executed, I
    added it _for 3 minutes_ only to test PREfast. Such a binary will never be

    The actual code is:

    call to my function which releases the spinlock within (and UnlockIrql is
    passed via parameter), the function is properly annotated and is also used in
    several other places, where all is fine

    This offended PREfast, so I added - just to check PREfast - the
    KeReleaseSpinLock call just before IoCompleteRequest. Yes, a false positive.
    The "my function" mentioned above surely has __drv_releasesResource(SpinLock)
    and this worked in other places it is used.
    Maxim S. Shatskih, Mar 14, 2008
  4. annotate the function which releases the lock to indicate the lock is being
    released in this subfunction and pfd should be happy

    Doron Holan [MSFT], Mar 14, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.