All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: QintaoShen <unSimple1993@163.com>
Cc: "Kuehling, Felix" <Felix.Kuehling@amd.com>,
	LKML <linux-kernel@vger.kernel.org>,
	amd-gfx list <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v1] drm/amdkfd: Check for potential null return of kmalloc_array()
Date: Thu, 24 Mar 2022 15:51:09 -0400	[thread overview]
Message-ID: <CADnq5_PkpohP3zYxMMoS7i_nRxTZfg0d3tiwPQA2hK3RFHVjMw@mail.gmail.com> (raw)
In-Reply-To: <1648110383-3533-1-git-send-email-unSimple1993@163.com>

Applied.  Thanks!

Alex

On Thu, Mar 24, 2022 at 9:46 AM QintaoShen <unSimple1993@163.com> wrote:
>
> As the kmalloc_array() may return null, the 'event_waiters[i].wait' would lead to null-pointer dereference.
> Therefore, it is better to check the return value of kmalloc_array() to avoid this confusion.
>
> Signed-off-by: QintaoShen <unSimple1993@163.com>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_events.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
> index deeccce..64f4a51 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
> @@ -749,6 +749,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events)
>         event_waiters = kmalloc_array(num_events,
>                                         sizeof(struct kfd_event_waiter),
>                                         GFP_KERNEL);
> +       if (!event_waiters)
> +               return NULL;
>
>         for (i = 0; (event_waiters) && (i < num_events) ; i++) {
>                 init_wait(&event_waiters[i].wait);
> --
> 2.7.4
>

      reply	other threads:[~2022-03-24 19:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24  8:26 [PATCH v1] drm/amdkfd: Check for potential null return of kmalloc_array() QintaoShen
2022-03-24  8:26 ` QintaoShen
2022-03-24 19:51 ` Alex Deucher [this message]

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=CADnq5_PkpohP3zYxMMoS7i_nRxTZfg0d3tiwPQA2hK3RFHVjMw@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=unSimple1993@163.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.