From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Benjamin Romer <benjamin.romer@unisys.com>,
David Kershner <david.kershner@unisys.com>,
Ken Cox <jkc@redhat.com>,
Erik Arfvidson <erik.arfvidson@unisys.com>,
Silvio F <silvio.fricke@gmail.com>,
sparmaintainer@unisys.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: unisys: virtpci: virtpci.c: Fix for possible null pointer dereference
Date: Sun, 14 Dec 2014 14:41:23 -0800 [thread overview]
Message-ID: <20141214224123.GA4288@kroah.com> (raw)
In-Reply-To: <1418596871-24827-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
On Sun, Dec 14, 2014 at 11:41:11PM +0100, 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/unisys/virtpci/virtpci.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c
> index ee9f826..d818eda 100644
> --- a/drivers/staging/unisys/virtpci/virtpci.c
> +++ b/drivers/staging/unisys/virtpci/virtpci.c
> @@ -1314,15 +1314,13 @@ static ssize_t virtpci_driver_attr_show(struct kobject *kobj,
> ssize_t ret = 0;
>
> struct driver_private *dprivate = to_driver(kobj);
> - struct device_driver *driver;
>
> - if (dprivate != NULL)
> - driver = dprivate->driver;
> - else
> - driver = NULL;
> + if (dprivate) {
It is impossible for dprivate to ever be NULL, someone doesn't
understand how kobjects work :(
So just remove the check please, don't add more logic that will never
run.
thanks,
greg k-h
prev parent reply other threads:[~2014-12-14 22:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-14 22:41 [PATCH] staging: unisys: virtpci: virtpci.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-12-14 22:41 ` Greg Kroah-Hartman [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=20141214224123.GA4288@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=benjamin.romer@unisys.com \
--cc=david.kershner@unisys.com \
--cc=devel@driverdev.osuosl.org \
--cc=erik.arfvidson@unisys.com \
--cc=jkc@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=silvio.fricke@gmail.com \
--cc=sparmaintainer@unisys.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