Skip to content

Commit c3d576b

Browse files
Dan Carpentergregkh
authored andcommitted
dma-buf: fix an error pointer vs NULL bug
commit 00ae149 upstream. Smatch detected potential error pointer dereference. drivers/gpu/drm/drm_syncobj.c:888 drm_syncobj_transfer_to_timeline() error: 'fence' dereferencing possible ERR_PTR() The error pointer comes from dma_fence_allocate_private_stub(). One caller expected error pointers and one expected NULL pointers. Change it to return NULL and update the caller which expected error pointers, drm_syncobj_assign_null_handle(), to check for NULL instead. Fixes: f781f66 ("dma-buf: keep the signaling time of merged fences v3") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Christian König <[email protected]> Reviewed-by: Sumit Semwal <[email protected]> Signed-off-by: Sumit Semwal <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Cc: Jindong Yue <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 23acc2b commit c3d576b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/dma-buf/dma-fence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp)
160160

161161
fence = kzalloc(sizeof(*fence), GFP_KERNEL);
162162
if (fence == NULL)
163-
return ERR_PTR(-ENOMEM);
163+
return NULL;
164164

165165
dma_fence_init(fence,
166166
&dma_fence_stub_ops,

drivers/gpu/drm/drm_syncobj.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
355355
{
356356
struct dma_fence *fence = dma_fence_allocate_private_stub(ktime_get());
357357

358-
if (IS_ERR(fence))
359-
return PTR_ERR(fence);
358+
if (!fence)
359+
return -ENOMEM;
360360

361361
drm_syncobj_replace_fence(syncobj, fence);
362362
dma_fence_put(fence);

0 commit comments

Comments
 (0)