From: Dan Carpenter <dan.carpenter@oracle.com>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: martyn@welchs.me.uk, manohar.vanga@gmail.com,
gregkh@linuxfoundation.org, alexandre.belloni@bootlin.com,
rafael@kernel.org, mathieu.poirier@linaro.org,
u.kleine-koenig@pengutronix.de, arnd@arndb.de,
linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev,
Kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] vme: Added NULL check for bridge
Date: Mon, 20 Jun 2022 11:49:49 +0300 [thread overview]
Message-ID: <20220620084949.GG16517@kadam> (raw)
In-Reply-To: <20220619070645.100947-1-jrdr.linux@gmail.com>
On Sun, Jun 19, 2022 at 12:36:45PM +0530, Souptick Joarder wrote:
> From: "Souptick Joarder (HPE)" <jrdr.linux@gmail.com>
>
> Kernel test robot throws below warning ->
> drivers/staging/vme_user/vme.c:662:20: warning: dereference
> of NULL 'bridge' [CWE-476] [-Wanalyzer-null-dereference]
>
> Added a NULL check.
>
> Reported-by: Kernel test robot <lkp@intel.com>
> Signed-off-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
> ---
> drivers/staging/vme_user/vme.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vme_user/vme.c b/drivers/staging/vme_user/vme.c
> index b5555683a069..ede774f2fe5a 100644
> --- a/drivers/staging/vme_user/vme.c
> +++ b/drivers/staging/vme_user/vme.c
> @@ -659,7 +659,7 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
> struct vme_master_resource *image;
> size_t length;
>
> - if (!bridge->master_read) {
> + if (bridge && !bridge->master_read) {
This patch does not help anything. If "bridge" is NULL here then the
kernel will just crash later in the function. Smatch complains about it
now:
drivers/staging/vme_user/vme.c:688 vme_master_read() error: we previously assumed 'bridge' could be null (see line 666)
However, I don't believe that bridge can actually be NULL here. We do
not write code just to silence that static checker false positives. Fix
the checker instead.
regards,
dan carpenter
prev parent reply other threads:[~2022-06-20 8:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-19 7:06 [PATCH] vme: Added NULL check for bridge Souptick Joarder
2022-06-20 8:02 ` Greg KH
2022-06-20 8:49 ` 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=20220620084949.GG16517@kadam \
--to=dan.carpenter@oracle.com \
--cc=alexandre.belloni@bootlin.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=jrdr.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=lkp@intel.com \
--cc=manohar.vanga@gmail.com \
--cc=martyn@welchs.me.uk \
--cc=mathieu.poirier@linaro.org \
--cc=rafael@kernel.org \
--cc=u.kleine-koenig@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox