diff options
author | Pavel Sakharov <p.sakharov@ispras.ru> | 2024-03-20 04:15:23 +0500 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2024-03-20 10:15:45 +0100 |
commit | 2295bd846765c766701e666ed2e4b35396be25e6 (patch) | |
tree | e075d41d9b0637ffa68b08c7590faf146ada8136 /drivers | |
parent | 9cbd1dae842737bfafa4b10a87909fa209dde250 (diff) |
dma-buf: Fix NULL pointer dereference in sanitycheck()
If due to a memory allocation failure mock_chain() returns NULL, it is
passed to dma_fence_enable_sw_signaling() resulting in NULL pointer
dereference there.
Call dma_fence_enable_sw_signaling() only if mock_chain() succeeds.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d62c43a953ce ("dma-buf: Enable signaling on fence for selftests")
Signed-off-by: Pavel Sakharov <p.sakharov@ispras.ru>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240319231527.1821372-1-p.sakharov@ispras.ru
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dma-buf/st-dma-fence-chain.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c index 9c2a0c082a76..ed4b323886e4 100644 --- a/drivers/dma-buf/st-dma-fence-chain.c +++ b/drivers/dma-buf/st-dma-fence-chain.c @@ -84,11 +84,11 @@ static int sanitycheck(void *arg) return -ENOMEM; chain = mock_chain(NULL, f, 1); - if (!chain) + if (chain) + dma_fence_enable_sw_signaling(chain); + else err = -ENOMEM; - dma_fence_enable_sw_signaling(chain); - dma_fence_signal(f); dma_fence_put(f); |