Skip to contentSkip to conversation

drm/i915/selftests: fix uninitialized variable sum when summing up values

PATCH In review Colin King 3 participants 3 messages Dec 10, 2019

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/i915/selftests: fix uninitialized variable sum when summing up values

From: Colin Ian King <[email protected]>

Currently the variable sum is not uninitialized and hence will cause an incorrect result in the summation values. Fix this by initializing sum to the first item in the summation.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes 3c7a44bbbfa7 ("drm/i915/selftests: Perform some basic cycle counting of MI ops")
---
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/selftest_engine_cs.c +1 -1
index 761d81f4bd68..f88e445a1cae 100644
@@ -108,7 +108,7 @@ static u32 trifilter(u32 *a)
 
 	sort(a, COUNT, sizeof(*a), cmp_u32, NULL);
 
-	sum += mul_u32_u32(a[2], 2);
+	sum = mul_u32_u32(a[2], 2);
 	sum += a[1];
 	sum += a[3];
 
Signature · 1 line
2.24.0
Reviewed-by on v1 1/1
#1 lore raw

Quoting Colin King (2019-12-10 14:32:05)

Quoted 18 lines

From: Colin Ian King <[email protected]>

Currently the variable sum is not uninitialized and hence will cause an incorrect result in the summation values. Fix this by initializing sum to the first item in the summation.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes 3c7a44bbbfa7 ("drm/i915/selftests: Perform some basic cycle counting of MI ops")
---
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/selftest_engine_cs.c +0 -0
index 761d81f4bd68..f88e445a1cae 100644

drivers/gpu/drm/i915/gt/selftest_engine_cs.c static u32 trifilter(u32 *a) · line 111

Quoted 5 lines
drivers/gpu/drm/i915/gt/selftest_engine_cs.c +1 -1
@@ -108,7 +108,7 @@ static u32 trifilter(u32 *a)
 
        sort(a, COUNT, sizeof(*a), cmp_u32, NULL);
 
-       sum += mul_u32_u32(a[2], 2);
+       sum = mul_u32_u32(a[2], 2);

/o\

-Chris

#2 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/selftests: fix uninitialized variable sum when summing up values

In reply to Colin King
== Series Details ==

== Series Details ==

Series: drm/i915/selftests: fix uninitialized variable sum when summing up values
URL : https://patchwork.freedesktop.org/series/70689/
State : failure

== Summary ==

Applying: drm/i915/selftests: fix uninitialized variable sum when summing up values Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/gt/selftest_engine_cs.c
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx