From: Colin King <colin.king@canonical.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] drivers: base: swnode: check if swnode is null before dereferencing it
Date: Sat, 22 Dec 2018 12:43:33 +0000 [thread overview]
Message-ID: <20181222124333.13561-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
The macro to_software_mode can potentially return NULL, so also add
a null check on the swnode before dereferencing it to avoid any null
pointer dereferences.
Detected by CoverityScan, CID#1476052 ("Explicit null dereferenced")
Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/base/swnode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 306bb93287af..204aa7d049e0 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -477,7 +477,8 @@ software_node_get_parent(const struct fwnode_handle *fwnode)
{
struct software_node *swnode = to_software_node(fwnode);
- return swnode->parent ? &swnode->parent->fwnode : NULL;
+ return swnode ? (swnode->parent ? &swnode->parent->fwnode : NULL) :
+ NULL;
}
struct fwnode_handle *
--
2.19.1
next reply other threads:[~2018-12-22 12:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-22 12:43 Colin King [this message]
2018-12-27 8:59 ` [PATCH][next] drivers: base: swnode: check if swnode is null before dereferencing it Rafael J. Wysocki
2019-01-02 12:01 ` 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=20181222124333.13561-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/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