From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org,
"Christian König" <christian.koenig@amd.com>,
linux-media@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
Date: Tue, 29 Mar 2022 10:48:10 +0200 [thread overview]
Message-ID: <YkLHypwNnLd+qA4H@phenom.ffwll.local> (raw)
In-Reply-To: <20220329070001.134180-2-christian.koenig@amd.com>
On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> A bug inside the new sync-file merge code created empty dma_fence_array instances.
>
> Warn about that and handle those without crashing.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-array.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 52b85d292383..5c8a7084577b 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> struct dma_fence_array *array;
> size_t size = sizeof(*array);
>
> + WARN_ON(!num_fences || !fences);
WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
if (WARN_ON)
return NULL;
with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +
> /* Allocate the callback structures behind the array. */
> size += num_fences * sizeof(struct dma_fence_array_cb);
> array = kzalloc(size, GFP_KERNEL);
> @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> if (!array)
> return head;
>
> + if (!array->num_fences)
> + return NULL;
> +
> return array->fences[0];
> }
> EXPORT_SYMBOL(dma_fence_array_first);
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2022-03-29 8:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 7:00 [Intel-gfx] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code Christian König
2022-03-29 7:00 ` [Intel-gfx] [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully Christian König
2022-03-29 8:48 ` Daniel Vetter [this message]
2022-03-29 8:49 ` Daniel Vetter
2022-03-29 7:07 ` [Intel-gfx] [Linaro-mm-sig] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code Thomas Hellström
2022-03-29 8:46 ` [Intel-gfx] " Daniel Vetter
2022-03-29 8:49 ` Christian König
2022-03-29 8:55 ` Das, Nirmoy
2022-03-29 13:10 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/2] " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YkLHypwNnLd+qA4H@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox