public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH] dma-buf: st: fix error handling in test_get_fences()
Date: Tue, 26 Oct 2021 12:55:47 +0200	[thread overview]
Message-ID: <52f6a48a-cd94-da21-2cda-300fd1f78a44@amd.com> (raw)
In-Reply-To: <20211026083448.3471055-1-arnd@kernel.org>

Am 26.10.21 um 10:34 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The new driver incorrectly unwinds after errors, as clang points out:
>
> drivers/dma-buf/st-dma-resv.c:295:7: 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:295:3: note: remove the 'if' if its condition is always false
>                  if (r) {
>                  ^~~~~~~~
> 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
>
> Skip cleaning up the bits that have not been allocated at this point.
>
> Fixes: 1d51775cd3f5 ("dma-buf: add dma_resv selftest v4")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

I already send out a patch to fix this up, but forgot to fix both gotos.

Going to add my rb and using that one here instead.

Thanks,
Christian.

> ---
> I'm not familiar with these interfaces, so I'm just guessing where
> we should jump after an error, please double-check and fix if necessary.
> ---
>   drivers/dma-buf/st-dma-resv.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
> index 6f3ba756da3e..bc32b3eedcb6 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_resv;
>   	}
>   
>   	if (shared) {
> @@ -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_resv;
>   		}
>   
>   		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_resv:
>   	dma_resv_fini(&resv);
>   	dma_fence_put(f);
>   	return r;


  reply	other threads:[~2021-10-26 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26  8:34 [PATCH] dma-buf: st: fix error handling in test_get_fences() Arnd Bergmann
2021-10-26 10:55 ` Christian König [this message]
2021-10-26 14:04 ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52f6a48a-cd94-da21-2cda-300fd1f78a44@amd.com \
    --to=christian.koenig@amd.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tvrtko.ursulin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox