From: Dan Carpenter <dan.carpenter@linaro.org>
To: Yuesong Li <liyuesong@vivo.com>
Cc: gregkh@linuxfoundation.org, soumya.negi97@gmail.com,
piroyangg@gmail.com, andi.shyti@linux.intel.com,
alexondunkan@gmail.com, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, opensource.kernel@vivo.com
Subject: Re: [PATCH v1] driver:staging:vme:Remove NULL check of list_entry()
Date: Thu, 22 Aug 2024 12:52:28 +0300 [thread overview]
Message-ID: <3e6423eb-0845-4ab2-8d92-86da2c814569@stanley.mountain> (raw)
In-Reply-To: <20240822025736.1208339-1-liyuesong@vivo.com>
I think Greg may have already merged your commit, which I'm okay with
because so far as I can see it's fine. But there should normally be
some additional analysis for this type of patch.
On Thu, Aug 22, 2024 at 10:57:36AM +0800, Yuesong Li wrote:
> list_entry() will never return a NULL pointer, thus remove the
> check.
>
This is true. But the other possibility here is that it could be that
list_entry_or_null() was intended.
In other words, sure, this patch doesn't introduce new crashing bugs, but it
might going against the work that static checker developers do to find risky
code.
The first thing I would do would be to see which commit introduced this.
git log -p --follow drivers/staging/vme_user/vme.c
This issue was introduced in 2009. Probably if the code has been this way for
15 years and no one has complained then it's fine to remove the NULL check.
To be honest, that's probably all the analysis you need. :P I did a little bit
more analysis using Smatch. These are the places where Smatch says that
->entry is set. You'd have to build the cross function database using
~/smatch/smatch_scripts/build_kernel_data.sh and then run
`smatch/smatch_data/db/smdb.py where vme_resource entry`.
drivers/staging/vme_user/vme_user.c | vme_user_probe | (struct vme_resource)->entry | min-max
drivers/staging/vme_user/vme_user.c | vme_user_remove | (struct vme_resource)->entry | min-max
drivers/staging/vme_user/vme.c | vme_slave_request | (struct vme_resource)->entry | 0-u64max
drivers/staging/vme_user/vme.c | vme_slave_free | (struct vme_resource)->entry | min-max
drivers/staging/vme_user/vme.c | vme_master_request | (struct vme_resource)->entry | 0-u64max
drivers/staging/vme_user/vme.c | vme_master_free | (struct vme_resource)->entry | min-max
drivers/staging/vme_user/vme.c | vme_dma_request | (struct vme_resource)->entry | 0-u64max
drivers/staging/vme_user/vme.c | vme_dma_free | (struct vme_resource)->entry | min-max
drivers/staging/vme_user/vme.c | vme_lm_request | (struct vme_resource)->entry | 0-u64max
drivers/staging/vme_user/vme.c | vme_lm_free | (struct vme_resource)->entry | min-max
When you look at the code, ->entry gets pointed to an entry in the list in the
request function and never modified again.
Which is slightly weird. In other words, struct vme_resource)->entry is not
used as a list at all so far as I can see. It's unclear to me what's going on
with vme, but I suspect we're going to remove it. See 35ba63b8f6d0 ("vme: move
back to staging"). Otherwise the temptation would be to ask that we set a
pointer directly to slave_image and master_image instead of saving a pointer to
entry.
regards,
dan carpenter
prev parent reply other threads:[~2024-08-22 9:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 2:57 [PATCH v1] driver:staging:vme:Remove NULL check of list_entry() Yuesong Li
2024-08-22 7:47 ` Greg KH
2024-08-22 9:52 ` 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=3e6423eb-0845-4ab2-8d92-86da2c814569@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=alexondunkan@gmail.com \
--cc=andi.shyti@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=liyuesong@vivo.com \
--cc=opensource.kernel@vivo.com \
--cc=piroyangg@gmail.com \
--cc=soumya.negi97@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