mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kuehling, Felix" <Felix.Kuehling@amd.com>
To: Allen Pais <allen.pais@oracle.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Cc: "airlied@linux.ie" <airlied@linux.ie>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/amdkfd: fix a potential NULL pointer dereference
Date: Thu, 19 Sep 2019 20:38:36 +0000	[thread overview]
Message-ID: <62826857-8364-262f-cbf8-17b15dbe0b09@amd.com> (raw)
In-Reply-To: <1568824231-4007-1-git-send-email-allen.pais@oracle.com>

On 2019-09-18 12:30 p.m., Allen Pais wrote:
> alloc_workqueue is not checked for errors and as a result,
> a potential NULL dereference could occur.
>
> Signed-off-by: Allen Pais <allen.pais@oracle.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> index c56ac47..caa82a8 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> @@ -62,6 +62,11 @@ int kfd_interrupt_init(struct kfd_dev *kfd)
>   	}
>   
>   	kfd->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1);
> +	if (unlikely(!kfd->ih_wq)) {
> +		fifo_free(&kfd->ih_fifo);

This does not compile. I think this should be kfifo_free.

> +		dev_err(kfd_chardev(), "Failed to allocate KFD IH workqueue\n");
> +		return kfd->ih_wq;

This throws a compiler warning "return makes integer from pointer 
without a cast". What's worse, kfd->ih_wq is NULL here and 
kfd_interrupt_init returns 0 to mean success, so returning a NULL 
pointer is definitely not what you want here. This function should 
return a negative error code on failure. I propose -ENOMEM.

I'm going to apply your patch with those fixes.

Regards,
   Felix


> +	}
>   	spin_lock_init(&kfd->interrupt_lock);
>   
>   	INIT_WORK(&kfd->interrupt_work, interrupt_wq);

      reply	other threads:[~2019-09-19 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 16:30 Allen Pais
2019-09-19 20:38 ` Kuehling, Felix [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=62826857-8364-262f-cbf8-17b15dbe0b09@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=airlied@linux.ie \
    --cc=allen.pais@oracle.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®