diff mbox series

drm/tests: Zero initialize fourccs_out

Message ID 20230901-zero-init-fourcc-list-test-v1-1-68bc4cc738c8@riseup.net (mailing list archive)
State New, archived
Headers show
Series drm/tests: Zero initialize fourccs_out | expand

Commit Message

Arthur Grillo Sept. 1, 2023, 6:52 p.m. UTC
fourccs_out array is not initialized. As the
drm_fb_build_fourcc_list() doesn't necessarily change all the array,
and the test compares all of it, the comparison could fail if the
array is not initialized. Zero initialize the array to fix this.

Fixes: 371e0b186a13 ("drm/tests: Add KUnit tests for drm_fb_build_fourcc_list()")
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
---
 drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 8e455145d8f163aefa6b9cc29478e0a9f82276e6
change-id: 20230901-zero-init-fourcc-list-test-2c934b6b7eb8

Best regards,

Comments

Maíra Canal Sept. 4, 2023, 9:08 p.m. UTC | #1
On 9/1/23 15:52, Arthur Grillo wrote:
> fourccs_out array is not initialized. As the
> drm_fb_build_fourcc_list() doesn't necessarily change all the array,
> and the test compares all of it, the comparison could fail if the
> array is not initialized. Zero initialize the array to fix this.
> 
> Fixes: 371e0b186a13 ("drm/tests: Add KUnit tests for drm_fb_build_fourcc_list()")
> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>

Reviewed-by: Maíra Canal <mairacanal@riseup.net>

Best Regards,
- Maíra

> ---
>   drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> index 79bc9d4bbd71..1a6bd291345d 100644
> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> @@ -1165,7 +1165,7 @@ KUNIT_ARRAY_PARAM(fb_build_fourcc_list, fb_build_fourcc_list_cases, fb_build_fou
>   static void drm_test_fb_build_fourcc_list(struct kunit *test)
>   {
>   	const struct fb_build_fourcc_list_case *params = test->param_value;
> -	u32 fourccs_out[TEST_BUF_SIZE];
> +	u32 fourccs_out[TEST_BUF_SIZE] = {0};
>   	size_t nfourccs_out;
>   	struct drm_device *drm;
>   	struct device *dev;
> 
> ---
> base-commit: 8e455145d8f163aefa6b9cc29478e0a9f82276e6
> change-id: 20230901-zero-init-fourcc-list-test-2c934b6b7eb8
> 
> Best regards,
Maíra Canal Sept. 8, 2023, 8:46 p.m. UTC | #2
Hi Arthur,

On 9/1/23 15:52, Arthur Grillo wrote:
> fourccs_out array is not initialized. As the
> drm_fb_build_fourcc_list() doesn't necessarily change all the array,
> and the test compares all of it, the comparison could fail if the
> array is not initialized. Zero initialize the array to fix this.
> 
> Fixes: 371e0b186a13 ("drm/tests: Add KUnit tests for drm_fb_build_fourcc_list()")
> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>

Applied to drm-misc/drm-misc-next!

Thanks!
- Maíra

> ---
>   drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> index 79bc9d4bbd71..1a6bd291345d 100644
> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> @@ -1165,7 +1165,7 @@ KUNIT_ARRAY_PARAM(fb_build_fourcc_list, fb_build_fourcc_list_cases, fb_build_fou
>   static void drm_test_fb_build_fourcc_list(struct kunit *test)
>   {
>   	const struct fb_build_fourcc_list_case *params = test->param_value;
> -	u32 fourccs_out[TEST_BUF_SIZE];
> +	u32 fourccs_out[TEST_BUF_SIZE] = {0};
>   	size_t nfourccs_out;
>   	struct drm_device *drm;
>   	struct device *dev;
> 
> ---
> base-commit: 8e455145d8f163aefa6b9cc29478e0a9f82276e6
> change-id: 20230901-zero-init-fourcc-list-test-2c934b6b7eb8
> 
> Best regards,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 79bc9d4bbd71..1a6bd291345d 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -1165,7 +1165,7 @@  KUNIT_ARRAY_PARAM(fb_build_fourcc_list, fb_build_fourcc_list_cases, fb_build_fou
 static void drm_test_fb_build_fourcc_list(struct kunit *test)
 {
 	const struct fb_build_fourcc_list_case *params = test->param_value;
-	u32 fourccs_out[TEST_BUF_SIZE];
+	u32 fourccs_out[TEST_BUF_SIZE] = {0};
 	size_t nfourccs_out;
 	struct drm_device *drm;
 	struct device *dev;