From: josh@joshtriplett.org
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Manu Gupta <manugupt1@gmail.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8188eu: os_dep: usb_intf.c: Fix for possible null pointer dereference
Date: Tue, 20 May 2014 16:57:56 -0700 [thread overview]
Message-ID: <20140520235756.GA23550@cloud> (raw)
In-Reply-To: <537BE4BB.4010308@lwfinger.net>
On Tue, May 20, 2014 at 06:26:51PM -0500, Larry Finger wrote:
> On 05/20/2014 04:31 PM, Rickard Strandqvist wrote:
> >There is otherwise a risk of a possible null pointer dereference.
> >
> >Was largely found by using a static code analysis program called cppcheck.
> >
> >Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> >---
> > drivers/staging/rtl8188eu/os_dep/usb_intf.c | 127 ++++++++++++++-------------
> > 1 file changed, 66 insertions(+), 61 deletions(-)
>
> Although cppcheck's analysis is correct, pointer padapter can never
> be null in any of these routines. In routine rtw_drv_init(),
> rtw_usb_if1_init() is called to allocate memory for struct adapter
> for the driver. If that fails, none of these other routines will
> ever be called as the driver will not be loaded.
>
> If it is deemed better to fill the code with needless tests because
> some static checker points out a place like this, that is OK with
> me, but I do not see the point.
If it's an invariant of the code that padapter cannot ever be NULL, then
that seems perfectly fine to rely on, and the tool just needs fixing or
silencing. At most, it might be helpful to add annotations like GCC's
"nonnull", if that helps the checker and the compiler generate more
useful warnings.
- Josh Triplett
next prev parent reply other threads:[~2014-05-20 23:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 21:31 [PATCH] staging: rtl8188eu: os_dep: usb_intf.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-05-20 21:57 ` Dan Carpenter
2014-05-20 23:26 ` Larry Finger
2014-05-20 23:57 ` josh [this message]
2014-05-21 7:24 ` Dan Carpenter
2014-05-21 21:51 ` Rickard Strandqvist
2014-05-21 22:12 ` Dan Carpenter
2014-05-20 23:55 ` 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=20140520235756.GA23550@cloud \
--to=josh@joshtriplett.org \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manugupt1@gmail.com \
--cc=rickard_strandqvist@spectrumdigital.se \
/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