From: "Kuehling, Felix" <Felix.Kuehling@amd.com>
To: Colin King <colin.king@canonical.com>,
Oded Gabbay <oded.gabbay@gmail.com>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
"Zhou, David(ChunMing)" <David1.Zhou@amd.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Zeng, Oak" <Oak.Zeng@amd.com>
Cc: "kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] drm/amdkfd: fix null pointer dereference on dev
Date: Wed, 29 May 2019 21:29:58 +0000 [thread overview]
Message-ID: <caa18dab-ac66-a909-1d94-3dc5604971da@amd.com> (raw)
In-Reply-To: <20190529150734.18120-1-colin.king@canonical.com>
On 2019-05-29 11:07 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The pointer dev is set to null yet it is being dereferenced when
> checking dev->dqm->sched_policy. Fix this by performing the check
> on dev->dqm->sched_policy after dev has been assigned and null
> checked. Also remove the redundant null assignment to dev.
>
> Addresses-Coverity: ("Explicit null dereference")
> Fixes: 1a058c337676 ("drm/amdkfd: New IOCTL to allocate queue GWS")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Thanks!
Felix
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index aab2aa6c1dee..ea82828fdc76 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1572,10 +1572,9 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep,
> {
> int retval;
> struct kfd_ioctl_alloc_queue_gws_args *args = data;
> - struct kfd_dev *dev = NULL;
> + struct kfd_dev *dev;
>
> - if (!hws_gws_support ||
> - dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS)
> + if (!hws_gws_support)
> return -EINVAL;
>
> dev = kfd_device_by_id(args->gpu_id);
> @@ -1583,6 +1582,8 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep,
> pr_debug("Could not find gpu id 0x%x\n", args->gpu_id);
> return -EINVAL;
> }
> + if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS)
> + return -EINVAL;
>
> mutex_lock(&p->mutex);
> retval = pqm_set_gws(&p->pqm, args->queue_id, args->num_gws ? dev->gws : NULL);
prev parent reply other threads:[~2019-05-29 21:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 15:07 [PATCH][next] drm/amdkfd: fix null pointer dereference on dev Colin King
2019-05-29 21:29 ` 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=caa18dab-ac66-a909-1d94-3dc5604971da@amd.com \
--to=felix.kuehling@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=David1.Zhou@amd.com \
--cc=Oak.Zeng@amd.com \
--cc=airlied@linux.ie \
--cc=amd-gfx@lists.freedesktop.org \
--cc=colin.king@canonical.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oded.gabbay@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox