LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kiran Padwal <kiran.padwal21@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference
Date: Thu, 5 Feb 2015 15:19:14 +0300 [thread overview]
Message-ID: <20150205121913.GE5336@mwanda> (raw)
In-Reply-To: <CAKXHbyOjB4SF_6LwqYnfgRj4cb3vTQDJfMeD0-xiAWoGHZPEuw@mail.gmail.com>
On Wed, Feb 04, 2015 at 06:46:34PM +0100, Rickard Strandqvist wrote:
> 2015-02-02 17:36 GMT+01:00 Sudip Mukherjee <sudipm.mukherjee@gmail.com>:
> > On Thu, Jan 29, 2015 at 07:46:10PM +0100, Rickard Strandqvist wrote:
> >> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> >> index 001348c..66b356e 100644
> >> --- a/drivers/staging/gdm724x/gdm_tty.c
> >> +++ b/drivers/staging/gdm724x/gdm_tty.c
> >> @@ -145,7 +145,7 @@ static int gdm_tty_recv_complete(void *data,
> >> struct gdm *gdm = tty_dev->gdm[index];
> >>
> >> if (!GDM_TTY_READY(gdm)) {
> >> - if (complete == RECV_PACKET_PROCESS_COMPLETE)
> >> + if (gdm && complete == RECV_PACKET_PROCESS_COMPLETE)
> > GDM_TTY_READY() is already checking for gdm, there is no chance that gdm can be null at this point. so this additional check is not required.
> >
> > regards
> > sudip
> >> gdm_tty_recv(gdm, gdm_tty_recv_complete);
> >> return TO_HOST_PORT_CLOSE;
> >> }
>
> Hi Sudip
>
> Yes, GDM_TTY_READY checks gdm, but this is a if(! )
>
You're right. But, by that same logic, we should also test
gdm->tty_dev. So it looks like this:
if (!GDM_TTY_READY(gdm)) {
if (gdm && gdm->tty_dev && complete == RECV_PACKET_PROCESS_COMPLETE)
gdm_tty_recv(gdm, gdm_tty_recv_complete);
return TO_HOST_PORT_CLOSE;
}
That is really sucky... Garbage code like this is why kernel style
doesn't favour macros. We should just open code GDM_TTY_READY() and
gdm_tty_recv() so that people can read the code.
I wonder if "gdm->tty_dev" is the same as the "tty_dev" parameter?
regards,
dan carpenter
prev parent reply other threads:[~2015-02-05 12:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 18:46 Rickard Strandqvist
2015-02-02 16:36 ` Sudip Mukherjee
2015-02-04 17:46 ` Rickard Strandqvist
2015-02-05 12:19 ` 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=20150205121913.GE5336@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kiran.padwal21@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=sudipm.mukherjee@gmail.com \
--subject='Re: [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).