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
    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?

    http://msdn2.microsoft.com/en-us/library/cc264096.aspx

    Unless, of course, I misunderstood what you wrote.

    Don
     
    0dbell, Mar 14, 2008
    #2
    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
    executed.

    The actual code is:

    KeAcquireSpinLock
    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
    IoCompleteRequest

    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
    #3
  4. annotate the function which releases the lock to indicate the lock is being
    released in this subfunction and pfd should be happy

    d
     
    Doron Holan [MSFT], Mar 14, 2008
    #4
    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.