Skip to content

Commit eabf131

Browse files
Pave154gregkh
authored andcommitted
dma-buf: Fix NULL pointer dereference in sanitycheck()
[ Upstream commit 2295bd8 ] 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: d62c43a ("dma-buf: Enable signaling on fence for selftests") Signed-off-by: Pavel Sakharov <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent d603ebe commit eabf131

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/dma-buf/st-dma-fence-chain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ static int sanitycheck(void *arg)
8484
return -ENOMEM;
8585

8686
chain = mock_chain(NULL, f, 1);
87-
if (!chain)
87+
if (chain)
88+
dma_fence_enable_sw_signaling(chain);
89+
else
8890
err = -ENOMEM;
8991

90-
dma_fence_enable_sw_signaling(chain);
91-
9292
dma_fence_signal(f);
9393
dma_fence_put(f);
9494

0 commit comments

Comments
 (0)