mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: unit: fix valgrind errors in posix bitmap
Fix cases where valgrind reported conditional jump or move depends on uninitialised value(s) JIRA NVGPU-3098 Change-Id: I5699d1f8539ec29e6f1bac6452e216c72c4d9007 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2094640 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
b0973eacbb
commit
13ad8142ef
@@ -57,7 +57,7 @@ static unsigned long __find_next_bit(const unsigned long *addr,
|
||||
unsigned long start,
|
||||
bool invert)
|
||||
{
|
||||
unsigned long idx;
|
||||
unsigned long idx, idx_max;
|
||||
unsigned long w;
|
||||
unsigned long start_mask;
|
||||
|
||||
@@ -87,12 +87,18 @@ static unsigned long __find_next_bit(const unsigned long *addr,
|
||||
|
||||
start = round_up(start, BITS_PER_LONG);
|
||||
|
||||
idx_max = (n - 1) / BITS_PER_LONG;
|
||||
|
||||
/*
|
||||
* Find the first non-zero word taking into account start and
|
||||
* invert.
|
||||
*/
|
||||
while (!w) {
|
||||
idx++;
|
||||
if (idx > idx_max) {
|
||||
return n;
|
||||
}
|
||||
|
||||
start += BITS_PER_LONG;
|
||||
|
||||
w = addr[idx] ^ invert_mask;
|
||||
|
||||
@@ -199,7 +199,8 @@ static int test_find_first_bit(struct unit_module *m,
|
||||
* Now make sure that for full/empty bitmap find_next_*() returns
|
||||
* the size parameter.
|
||||
*/
|
||||
memset(words, args->find_zeros ? 0xff : 0x00, sizeof(words));
|
||||
memset(words, args->find_zeros ? 0xff : 0x00,
|
||||
NUM_WORDS * sizeof(words[0]));
|
||||
result = finder_function(words, NUM_WORDS * BITS_PER_LONG);
|
||||
if (result != NUM_WORDS * BITS_PER_LONG)
|
||||
unit_return_fail(m, "find_first_%s() failed with empty map\n",
|
||||
|
||||
Reference in New Issue
Block a user