Skip to contentSkip to conversation

drm/tests: probe_helper: Fix unitialized variable

PATCH Applied Maxime Ripard 2 participants 3 messages Dec 1, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tests: probe_helper: Fix unitialized variable

The len variable is used while uninitialized. Initialize it.

Fixes 1e4a91db109f ("drm/probe-helper: Provide a TV get_modes helper")
---
 drivers/gpu/drm/tests/drm_probe_helper_test.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_probe_helper_test.c +1 -0
index 7e938258c742..211131405500 100644
@@ -115,6 +115,7 @@ drm_test_connector_helper_tv_get_modes_check(struct kunit *test)
 	ret = drm_connector_helper_tv_get_modes(connector);
 	KUNIT_EXPECT_EQ(test, ret, params->num_expected_modes);
 
+	len = 0;
 	list_for_each_entry(mode, &connector->probed_modes, head)
 		len++;
 	KUNIT_EXPECT_EQ(test, len, params->num_expected_modes);
Signature · 1 line
2.38.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Maxime Ripard

The len variable is used while uninitialized. Initialize it.

Fixes 1e4a91db109f ("drm/probe-helper: Provide a TV get_modes helper")
---
 drivers/gpu/drm/tests/drm_probe_helper_test.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_probe_helper_test.c +0 -0
index 7e938258c742..211131405500 100644

drivers/gpu/drm/tests/drm_probe_helper_test.c drm_test_connector_helper_tv_get_modes_check(struct kunit *test) · line 118

Quoted 4 lines
drivers/gpu/drm/tests/drm_probe_helper_test.c +1 -0
@@ -115,6 +115,7 @@ drm_test_connector_helper_tv_get_modes_check(struct kunit *test)
 	ret = drm_connector_helper_tv_get_modes(connector);
 	KUNIT_EXPECT_EQ(test, ret, params->num_expected_modes);
 
+	len = 0;

I would probably do size_t len = 0; instead but don't have a strong opinion.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author Applied
#2 lore raw
In reply to Maxime Ripard
Quoted 3 lines · Maxime Ripard

The len variable is used while uninitialized. Initialize it.

Applied to drm/drm-misc (drm-misc-next).

Thanks!
Maxime