Commit 55d5e4f9 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Christian König

dma-buf: st: fix error handling in test_get_fences()

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: 1d51775c ("dma-buf: add dma_resv selftest v4")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20211026083448.3471055-1-arnd@kernel.orgSigned-off-by: default avatarChristian König <christian.koenig@amd.com>
parent 44653c40
...@@ -287,7 +287,7 @@ static int test_get_fences(void *arg, bool shared) ...@@ -287,7 +287,7 @@ static int test_get_fences(void *arg, bool shared)
r = dma_resv_lock(&resv, NULL); r = dma_resv_lock(&resv, NULL);
if (r) { if (r) {
pr_err("Resv locking failed\n"); pr_err("Resv locking failed\n");
goto err_free; goto err_resv;
} }
if (shared) { if (shared) {
...@@ -295,7 +295,7 @@ static int test_get_fences(void *arg, bool shared) ...@@ -295,7 +295,7 @@ static int test_get_fences(void *arg, bool shared)
if (r) { if (r) {
pr_err("Resv shared slot allocation failed\n"); pr_err("Resv shared slot allocation failed\n");
dma_resv_unlock(&resv); dma_resv_unlock(&resv);
goto err_free; goto err_resv;
} }
dma_resv_add_shared_fence(&resv, f); dma_resv_add_shared_fence(&resv, f);
...@@ -336,6 +336,7 @@ static int test_get_fences(void *arg, bool shared) ...@@ -336,6 +336,7 @@ static int test_get_fences(void *arg, bool shared)
while (i--) while (i--)
dma_fence_put(fences[i]); dma_fence_put(fences[i]);
kfree(fences); kfree(fences);
err_resv:
dma_resv_fini(&resv); dma_resv_fini(&resv);
dma_fence_put(f); dma_fence_put(f);
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment