From: Colin King <colin.king@canonical.com>
To: Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Ben Widawsky <ben.widawsky@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-cxl@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] cxl/core: Fix a deference of a pointer cxl_port before it is null checked
Date: Sun, 29 Aug 2021 18:15:53 +0100 [thread overview]
Message-ID: <20210829171553.532596-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
The assignment of pointer port with a dereference of pointer cxl_port
occurs before cxl_port is null checked. Fix this by only assigning port
once cxl_port has been null checked.
Addresses-Coverity: ("Dereference before null check")
Fixes: b7ca54b62551 ("cxl/core: Split decoder setup into alloc + add")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/cxl/core/bus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/cxl/core/bus.c b/drivers/cxl/core/bus.c
index 0b85351be6bf..55db46ba8a18 100644
--- a/drivers/cxl/core/bus.c
+++ b/drivers/cxl/core/bus.c
@@ -494,7 +494,7 @@ EXPORT_SYMBOL_GPL(cxl_decoder_alloc);
int devm_cxl_add_decoder(struct device *host, struct cxl_decoder *cxld,
int *target_map)
{
- struct cxl_port *port = to_cxl_port(cxld->dev.parent);
+ struct cxl_port *port;
struct device *dev;
int rc = 0, i;
@@ -509,6 +509,7 @@ int devm_cxl_add_decoder(struct device *host, struct cxl_decoder *cxld,
goto err;
}
+ port = to_cxl_port(cxld->dev.parent);
device_lock(&port->dev);
if (list_empty(&port->dports))
rc = -EINVAL;
--
2.32.0
reply other threads:[~2021-08-29 17:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210829171553.532596-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.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;
as well as URLs for NNTP newsgroup(s).