All of lore.kernel.org
 help / color / mirror / Atom feed
From: sunliming@linux.dev
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: lyude@redhat.com, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com,
	simona@ffwll.ch, dri-devel@lists.freedesktop.org,
	nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	"sunliming" <sunliming@kylinos.cn>
Subject: Re: [PATCH] drm/nouveau/gsp: Fix possible NULL pointer dereference warning in r535_dmac_alloc
Date: Mon, 20 Apr 2026 01:09:39 +0000	[thread overview]
Message-ID: <ea7bdf986e2c50c52d63de1d76eba3ca8c65ae17@linux.dev> (raw)
In-Reply-To: <DHW9RZVWDN6Y.2G2RKSJMF5ESB@kernel.org>

2026年4月18日 20:12, "Danilo Krummrich" <dakr@kernel.org mailto:dakr@kernel.org?to=%22Danilo%20Krummrich%22%20%3Cdakr%40kernel.org%3E > 写到:


> 
> On Sat Apr 18, 2026 at 9:14 AM CEST, sunliming wrote:
> 
> > 
> > From: sunliming <sunliming@kylinos.cn>
> > 
> >  Fix below smatch warnings:
> >  drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c:178 r535_dmac_alloc()
> >  warn: 'args' can also be NULL
> > 
> Please write a commit description that explains also the underlying problem; see
> more below.
> 
> > 
> > Signed-off-by: sunliming <sunliming@kylinos.cn>
> >  ---
> >  drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> >  diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
> >  index 6e63df816d85..6dec2623d0be 100644
> >  --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
> >  +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
> >  @@ -172,6 +172,8 @@ r535_dmac_alloc(struct nvkm_disp *disp, u32 oclass, int inst, u32 put_offset,
> >  
> >  args = nvkm_gsp_rm_alloc_get(&disp->rm.object, (oclass << 16) | inst, oclass,
> >  sizeof(*args), dmac);
> >  + if (!args)
> >  + return -ENOMEM;
> > 
> Are we sure that this can ever return NULL in the first place? I know that
> nvkm_gsp_rm_alloc_get() internally checks for IS_ERR_OR_NULL(), but I couldn't
> find anything within the callchain that would actually return NULL.
> 
> That said, I think IS_ERR_OR_NULL() checks are misleading.
> 
I also believe that the nvkm_gsp_rm_alloc_get function will not return NULL. My patch 
was merely intended to suppress a compiler warning and to guard against possible future 
changes in the implementation of nvkm_gsp_rm_alloc_get. Of course, the patch may be 
unnecessary, and I will defer to the maintainers' review conclusion.

Thanks.
> > 
> > if (IS_ERR(args))
> >  return PTR_ERR(args);
> >  
> >  -- 
> >  2.25.1
> >
>

WARNING: multiple messages have this Message-ID (diff)
From: sunliming@linux.dev
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	simona@ffwll.ch, dri-devel@lists.freedesktop.org,
	nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	sunliming <sunliming@kylinos.cn>
Subject: Re: [PATCH] drm/nouveau/gsp: Fix possible NULL pointer dereference warning in r535_dmac_alloc
Date: Mon, 20 Apr 2026 01:09:39 +0000	[thread overview]
Message-ID: <ea7bdf986e2c50c52d63de1d76eba3ca8c65ae17@linux.dev> (raw)
In-Reply-To: <DHW9RZVWDN6Y.2G2RKSJMF5ESB@kernel.org>

2026年4月18日 20:12, "Danilo Krummrich" <dakr@kernel.org mailto:dakr@kernel.org?to=%22Danilo%20Krummrich%22%20%3Cdakr%40kernel.org%3E > 写到:


> 
> On Sat Apr 18, 2026 at 9:14 AM CEST, sunliming wrote:
> 
> > 
> > From: sunliming <sunliming@kylinos.cn>
> > 
> >  Fix below smatch warnings:
> >  drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c:178 r535_dmac_alloc()
> >  warn: 'args' can also be NULL
> > 
> Please write a commit description that explains also the underlying problem; see
> more below.
> 
> > 
> > Signed-off-by: sunliming <sunliming@kylinos.cn>
> >  ---
> >  drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> >  diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
> >  index 6e63df816d85..6dec2623d0be 100644
> >  --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
> >  +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
> >  @@ -172,6 +172,8 @@ r535_dmac_alloc(struct nvkm_disp *disp, u32 oclass, int inst, u32 put_offset,
> >  
> >  args = nvkm_gsp_rm_alloc_get(&disp->rm.object, (oclass << 16) | inst, oclass,
> >  sizeof(*args), dmac);
> >  + if (!args)
> >  + return -ENOMEM;
> > 
> Are we sure that this can ever return NULL in the first place? I know that
> nvkm_gsp_rm_alloc_get() internally checks for IS_ERR_OR_NULL(), but I couldn't
> find anything within the callchain that would actually return NULL.
> 
> That said, I think IS_ERR_OR_NULL() checks are misleading.
> 
I also believe that the nvkm_gsp_rm_alloc_get function will not return NULL. My patch 
was merely intended to suppress a compiler warning and to guard against possible future 
changes in the implementation of nvkm_gsp_rm_alloc_get. Of course, the patch may be 
unnecessary, and I will defer to the maintainers' review conclusion.

Thanks.
> > 
> > if (IS_ERR(args))
> >  return PTR_ERR(args);
> >  
> >  -- 
> >  2.25.1
> >
>

  parent reply	other threads:[~2026-04-20  1:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-18  7:14 [PATCH] drm/nouveau/gsp: Fix possible NULL pointer dereference warning in r535_dmac_alloc sunliming
2026-04-18  7:14 ` sunliming
2026-04-18 12:12 ` Danilo Krummrich
2026-04-18 12:12   ` Danilo Krummrich
2026-04-18 17:24   ` Timur Tabi
2026-04-18 17:35     ` Danilo Krummrich
2026-04-18 17:44       ` Timur Tabi
2026-04-18 20:43         ` Danilo Krummrich
2026-04-20  1:09   ` sunliming [this message]
2026-04-20  1:09     ` sunliming

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=ea7bdf986e2c50c52d63de1d76eba3ca8c65ae17@linux.dev \
    --to=sunliming@linux.dev \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=sunliming@kylinos.cn \
    --cc=tzimmermann@suse.de \
    /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.