[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1422557426-3929-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Thu, 29 Jan 2015 19:50:26 +0100
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Benjamin Romer <benjamin.romer@...sys.com>,
David Kershner <david.kershner@...sys.com>
Cc: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Bryan Thompson <bryan.thompson@...sys.com>,
Ken Cox <jkc@...hat.com>,
Erik Arfvidson <erik.arfvidson@...sys.com>,
sparmaintainer@...sys.com, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] staging: unisys: virtpci: virtpci: Fix for possible null pointer dereference
Fix a possible null pointer dereference, there is
otherwise a risk of a possible null pointer dereference.
This was found using a static code analysis program called cppcheck
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
---
drivers/staging/unisys/virtpci/virtpci.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c
index 39b828d..eea3c64 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -1340,16 +1340,16 @@ static ssize_t virtpci_driver_attr_show(struct kobject *kobj,
struct driver_private *dprivate = to_driver(kobj);
struct device_driver *driver;
- if (dprivate != NULL)
+ if (dprivate != NULL) {
driver = dprivate->driver;
- else
- driver = NULL;
- DBGINF("In virtpci_driver_attr_show driver->name:%s\n", driver->name);
- if (driver) {
+ DBGINF("In virtpci_driver_attr_show driver->name:%s\n", driver->name);
+
if (dattr->show)
ret = dattr->show(driver, buf);
}
+ else
+ DBGINF("In virtpci_driver_attr_show driver:NULL\n");
return ret;
}
@@ -1363,17 +1363,17 @@ static ssize_t virtpci_driver_attr_store(struct kobject *kobj,
struct driver_private *dprivate = to_driver(kobj);
struct device_driver *driver;
- if (dprivate != NULL)
+ if (dprivate != NULL) {
driver = dprivate->driver;
- else
- driver = NULL;
- DBGINF("In virtpci_driver_attr_store driver->name:%s\n", driver->name);
+ DBGINF("In virtpci_driver_attr_store driver->name:%s\n", driver->name);
- if (driver) {
if (dattr->store)
ret = dattr->store(driver, buf, count);
}
+ else
+ DBGINF("In virtpci_driver_attr_store driver:NULL\n");
+
return ret;
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists