From: Dan Carpenter <dan.carpenter@linaro.org>
To: Kees Bakker <kees@ijzerbout.nl>
Cc: Paolo Perego <pperego@suse.de>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Dave Penkler <dpenkler@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] staging:gpib: Fix a dereference before null check issue
Date: Thu, 21 Nov 2024 10:37:30 +0300 [thread overview]
Message-ID: <b843f8a9-1562-458c-8f6a-c59b1037b756@stanley.mountain> (raw)
In-Reply-To: <6ca90e87-965a-4895-ba72-8144540f6e4c@ijzerbout.nl>
On Wed, Nov 20, 2024 at 08:54:16PM +0100, Kees Bakker wrote:
> Op 20-11-2024 om 18:04 schreef Dan Carpenter:
> > On Wed, Nov 20, 2024 at 03:46:53PM +0100, Paolo Perego wrote:
> > > This commit fixes a dereference before null check issue discovered by
> > > Coverity (CID 1601566).
> > >
> > > The check ad line 1450 suggests that a_priv can be NULL, however it has
> > > been derefenced before, in the interface_to_usbdev() call.
> > >
> > > Signed-off-by: Paolo Perego <pperego@suse.de>
> > > ---
> > You need a Fixes tag. But I'm pretty sure the correct fix is to remove the NULL
> > check.
> In the whole agilent_82357a.c module there is no consistency whether
> board->private_data needs to be checked for a NULL or not.
>
> If Dan is correct then it is better to drop the NULL check, not only here
> but in a few more places as well. There are at least 10 functions were
> there is no NULL check for private_data.
>
> Run this command and you'll see what I mean
> git grep -3 -e '->private_data' -- drivers/staging/gpib/agilent_82357a
>
I had looked at similar issue in a different driver:
https://lore.kernel.org/all/2d99b7a6-f427-4d54-bde7-fb3df5e19e53@stanley.mountain/
Here the NULL check we are discussing is the same thing. The private data is
allocated in attach() and freed in detach(). The detach has no need to check
for NULL because we can't detach something which isn't attached.
The other NULL checks are in agilent_82357a_driver_disconnect(),
agilent_82357a_driver_suspend() and agilent_82357a_driver_resume(). And there
the NULL checks are required because it could happen when the driver isn't
attached.
I also did a quick glance through to see if any of the functions which didn't
check for NULL should get a NULL check but they all seemed okay because either
the board was attached or the caller had a NULL check.
So I think we can just remove this one NULL check and everything else makes
sense.
regards,
dan carpenter
next prev parent reply other threads:[~2024-11-21 7:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 14:46 Paolo Perego
2024-11-20 16:42 ` [PATCH] staging: gpib: " Markus Elfring
2024-11-20 17:04 ` [PATCH] staging:gpib: " Dan Carpenter
2024-11-20 19:54 ` Kees Bakker
2024-11-21 7:37 ` Dan Carpenter [this message]
2024-11-21 14:10 ` Paolo Perego
2024-11-21 14:17 ` Dan Carpenter
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=b843f8a9-1562-458c-8f6a-c59b1037b756@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=arnd@arndb.de \
--cc=dpenkler@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kees@ijzerbout.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=pperego@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®