All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: fix uninitialized variable usage in selftests
@ 2021-10-25  7:28 Christian König
  2021-10-25 15:59 ` Alex Deucher
  2021-10-25 22:48 ` Nathan Chancellor
  0 siblings, 2 replies; 3+ messages in thread
From: Christian König @ 2021-10-25  7:28 UTC (permalink / raw)
  To: dri-devel

"i" can be used uninitialized in one of the error branches. Fix this.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reported-by: kernel test robot <lkp@intel.com>
---
 drivers/dma-buf/st-dma-resv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
index 6f3ba756da3e..bc2265807f6c 100644
--- a/drivers/dma-buf/st-dma-resv.c
+++ b/drivers/dma-buf/st-dma-resv.c
@@ -295,7 +295,7 @@ static int test_get_fences(void *arg, bool shared)
 		if (r) {
 			pr_err("Resv shared slot allocation failed\n");
 			dma_resv_unlock(&resv);
-			goto err_free;
+			goto err_fini;
 		}
 
 		dma_resv_add_shared_fence(&resv, f);
@@ -336,6 +336,7 @@ static int test_get_fences(void *arg, bool shared)
 	while (i--)
 		dma_fence_put(fences[i]);
 	kfree(fences);
+err_fini:
 	dma_resv_fini(&resv);
 	dma_fence_put(f);
 	return r;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: fix uninitialized variable usage in selftests
  2021-10-25  7:28 [PATCH] dma-buf: fix uninitialized variable usage in selftests Christian König
@ 2021-10-25 15:59 ` Alex Deucher
  2021-10-25 22:48 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2021-10-25 15:59 UTC (permalink / raw)
  To: Christian König; +Cc: Maling list - DRI developers

On Mon, Oct 25, 2021 at 3:28 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> "i" can be used uninitialized in one of the error branches. Fix this.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Reported-by: kernel test robot <lkp@intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/dma-buf/st-dma-resv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
> index 6f3ba756da3e..bc2265807f6c 100644
> --- a/drivers/dma-buf/st-dma-resv.c
> +++ b/drivers/dma-buf/st-dma-resv.c
> @@ -295,7 +295,7 @@ static int test_get_fences(void *arg, bool shared)
>                 if (r) {
>                         pr_err("Resv shared slot allocation failed\n");
>                         dma_resv_unlock(&resv);
> -                       goto err_free;
> +                       goto err_fini;
>                 }
>
>                 dma_resv_add_shared_fence(&resv, f);
> @@ -336,6 +336,7 @@ static int test_get_fences(void *arg, bool shared)
>         while (i--)
>                 dma_fence_put(fences[i]);
>         kfree(fences);
> +err_fini:
>         dma_resv_fini(&resv);
>         dma_fence_put(f);
>         return r;
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: fix uninitialized variable usage in selftests
  2021-10-25  7:28 [PATCH] dma-buf: fix uninitialized variable usage in selftests Christian König
  2021-10-25 15:59 ` Alex Deucher
@ 2021-10-25 22:48 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2021-10-25 22:48 UTC (permalink / raw)
  To: Christian König; +Cc: dri-devel, llvm

Hi Christian,

On Mon, Oct 25, 2021 at 09:28:35AM +0200, Christian König wrote:
> "i" can be used uninitialized in one of the error branches. Fix this.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Reported-by: kernel test robot <lkp@intel.com>
> ---
>  drivers/dma-buf/st-dma-resv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
> index 6f3ba756da3e..bc2265807f6c 100644
> --- a/drivers/dma-buf/st-dma-resv.c
> +++ b/drivers/dma-buf/st-dma-resv.c
> @@ -295,7 +295,7 @@ static int test_get_fences(void *arg, bool shared)
>  		if (r) {
>  			pr_err("Resv shared slot allocation failed\n");
>  			dma_resv_unlock(&resv);
> -			goto err_free;
> +			goto err_fini;
>  		}
>  
>  		dma_resv_add_shared_fence(&resv, f);
> @@ -336,6 +336,7 @@ static int test_get_fences(void *arg, bool shared)
>  	while (i--)
>  		dma_fence_put(fences[i]);
>  	kfree(fences);
> +err_fini:
>  	dma_resv_fini(&resv);
>  	dma_fence_put(f);
>  	return r;
> -- 
> 2.25.1
> 
> 

Thanks for the patch! This is not enough to fix all the warnings in this
file:

drivers/dma-buf/st-dma-resv.c:288:6: error: variable 'i' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
        if (r) {
            ^
drivers/dma-buf/st-dma-resv.c:336:9: note: uninitialized use occurs here
        while (i--)
               ^
drivers/dma-buf/st-dma-resv.c:288:2: note: remove the 'if' if its condition is always false
        if (r) {
        ^~~~~~~~
drivers/dma-buf/st-dma-resv.c:280:10: note: initialize the variable 'i' to silence this warning
        int r, i;
                ^
                 = 0
1 error generated.

This hunk resolves it for me. With that:

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
index bc2265807f6c..e5d5c25eed53 100644
--- a/drivers/dma-buf/st-dma-resv.c
+++ b/drivers/dma-buf/st-dma-resv.c
@@ -287,7 +287,7 @@ static int test_get_fences(void *arg, bool shared)
 	r = dma_resv_lock(&resv, NULL);
 	if (r) {
 		pr_err("Resv locking failed\n");
-		goto err_free;
+		goto err_fini;
 	}
 
 	if (shared) {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-25 22:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  7:28 [PATCH] dma-buf: fix uninitialized variable usage in selftests Christian König
2021-10-25 15:59 ` Alex Deucher
2021-10-25 22:48 ` Nathan Chancellor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.