From: Dan Carpenter <dan.carpenter@linaro.org>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [bug report] drm/xe/psmi: Add debugfs interface for PSMI
Date: Tue, 23 Sep 2025 08:39:05 +0300 [thread overview]
Message-ID: <aNIyeRv91gZXPUBr@stanley.mountain> (raw)
In-Reply-To: <dcfyppphvrn4xq63bqtfi5nd3ipsqkkhfehjdt77pyr2nlfmd4@xfmqlycgi3cm>
On Mon, Sep 22, 2025 at 03:52:40PM -0500, Lucas De Marchi wrote:
> On Tue, Aug 26, 2025 at 10:51:02AM +0300, Dan Carpenter wrote:
> > Hello Lucas De Marchi,
> >
> > Commit aaa0c1f50a3d ("drm/xe/psmi: Add debugfs interface for PSMI")
> > from Aug 21, 2025 (linux-next), leads to the following Smatch static
> > checker warning:
> >
> > drivers/gpu/drm/xe/xe_psmi.c:93 psmi_alloc_object()
> > error: 'bo' dereferencing possible ERR_PTR()
> >
> > drivers/gpu/drm/xe/xe_psmi.c
> > 68 static struct xe_bo *psmi_alloc_object(struct xe_device *xe,
> > 69 unsigned int id, size_t bo_size)
> > 70 {
> > 71 struct xe_bo *bo = NULL;
> > 72 struct xe_tile *tile;
> > 73 int err;
> > 74
> > 75 if (!id || !bo_size)
> > 76 return NULL;
> >
> > I really encourage everyone to document why functions return both error
> > pointers and NULL. Here "bo_size" can never actually be zero so that's
> > an impossible path. Presumably id can be zero, but what's the point of
> > storing a NULL in xe->psmi.capture_obj[0]? It feels like it complicates
> > things...
>
> neither id nor bo_size can be 0 at this point. We could simply remove
> the check or replace by
>
> xe_assert(xe, id);
> xe_assert(xe, bo_size);
That works, or you could return an error pointer. That would also be fine.
regards,
dan carpenter
prev parent reply other threads:[~2025-09-23 5:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 7:51 [bug report] drm/xe/psmi: Add debugfs interface for PSMI Dan Carpenter
2025-09-22 20:52 ` Lucas De Marchi
2025-09-23 5:39 ` Dan Carpenter [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=aNIyeRv91gZXPUBr@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.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