open-gpu-kernel-modules icon indicating copy to clipboard operation
open-gpu-kernel-modules copied to clipboard

always clear numPagesAlloc

Open trixirt opened this issue 3 years ago • 6 comments

Clang static analysis on RHEL reports this issue addrtree.c:1154:50: warning: The left operand of '/' is a garbage value [core.UndefinedBinaryOperatorResult] *numPagesAlloc += localNumPagesAlloc / 2; ~~~~~~~~~~~~~~~~~~ ^

_pmaAddrtreeScanContiguous() can return early with an error without setting numPagesAlloc. There are several uses of _pmaAddrtreeScanCantiguous() that do not check the status and depend on the setting of of numPageAlloc as a side effect.

To ensure the side effect is always valid, move the clearing of numPagesAlloc to before the early exit

Signed-off-by: Tom Rix [email protected]

trixirt avatar May 18 '22 13:05 trixirt

PR seems to have stalled, anything for me to do ?

trixirt avatar Jun 15 '22 20:06 trixirt

Hi! Thanks for checking back. I was out for a bit, but I'll handle it soon. This hasn't been forgotten.

niv avatar Jun 17 '22 17:06 niv

PR has stalled

trixirt avatar Jul 14 '22 12:07 trixirt

Could the real issue be that numPagesAlloc is being modified even when _pmaAddrtreeScanContiguous fails?


            status = _pmaAddrtreeScanContiguous(
                pMap,
                addrBase,
                rangeStart,
                rangeEnd,
                2,
                freeList + i,
                _PMA_64KB,
                alignment,
                &localNumPagesAlloc,
                bSkipEvict);
            // Give back the first of every two 64KB frames
            *numPagesAlloc += localNumPagesAlloc / 2;
            if (status != NV_OK)
            {
                return status;
            }

YusufKhan-gamedev avatar Jul 30 '22 22:07 YusufKhan-gamedev

Hi tom,

the change has bee applied internally, and will bubble up in a future release, at which point this PR will also go in. Same reasoning/details as explained in https://github.com/NVIDIA/open-gpu-kernel-modules/pull/330#issuecomment-1203811765.

Thanks for your contribution, and patience!

niv avatar Aug 11 '22 14:08 niv

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Tom Rix seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Sep 08 '24 15:09 CLAassistant