always clear numPagesAlloc
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]
PR seems to have stalled, anything for me to do ?
Hi! Thanks for checking back. I was out for a bit, but I'll handle it soon. This hasn't been forgotten.
PR has stalled
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;
}
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!
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.