From f69d21f3261aa03bf5786f4118c4298c1a821f38 Mon Sep 17 00:00:00 2001 From: jsg Date: Fri, 4 Aug 2023 09:36:28 +0000 Subject: [PATCH] dma-buf: fix an error pointer vs NULL bug From Dan Carpenter c3d576baa6c8f0b34750a0b6f9b12e9d64625512 in linux-6.1.y/6.1.43 00ae1491f970acc454be0df63f50942d94825860 in mainline linux --- sys/dev/pci/drm/drm_linux.c | 4 ++-- sys/dev/pci/drm/drm_syncobj.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index ecfc3ae318c..ab2afec94d4 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.102 2023/08/04 09:31:20 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.103 2023/08/04 09:36:28 jsg Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -2012,7 +2012,7 @@ dma_fence_allocate_private_stub(ktime_t ts) struct dma_fence *f = malloc(sizeof(*f), M_DRM, M_ZERO | M_WAITOK | M_CANFAIL); if (f == NULL) - return ERR_PTR(-ENOMEM); + return NULL; dma_fence_init(f, &dma_fence_stub_ops, &dma_fence_stub_mtx, 0, 0); dma_fence_signal_timestamp(f, ts); return f; diff --git a/sys/dev/pci/drm/drm_syncobj.c b/sys/dev/pci/drm/drm_syncobj.c index bd4aa4d0c63..922fe5ddf66 100644 --- a/sys/dev/pci/drm/drm_syncobj.c +++ b/sys/dev/pci/drm/drm_syncobj.c @@ -358,8 +358,8 @@ static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj) { struct dma_fence *fence = dma_fence_allocate_private_stub(ktime_get()); - if (IS_ERR(fence)) - return PTR_ERR(fence); + if (!fence) + return -ENOMEM; drm_syncobj_replace_fence(syncobj, fence); dma_fence_put(fence); -- 2.20.1