From: Kangjie Lu <kjlu@umn.edu>
To: kjlu@umn.edu
Cc: Sudeep Holla <sudeep.holla@arm.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, pakki001@umn.edu
Subject: [PATCH] firmware: arm_scmi: check return value of idr_find
Date: Mon, 25 Mar 2019 15:48:22 -0500 [thread overview]
Message-ID: <20190325204823.5428-1-kjlu@umn.edu> (raw)
In-Reply-To: <225abd6e-4551-213d-367b-93d938789188@arm.com>
Thanks for Steven Price's review of this patch. In the current code,
idr_find won't return NULL because the SCMI_PROTOCOL_BASE id must
exist. However, it might return NULL in the future code if the check
is on another node while processing the children in subsequent calls
to scmi_mbox_chan_setup().
Therefore, the patch conservatively checks the return value and
returns -EINVAL when it indeed failed.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-by: Steven Price <steven.price@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 8f952f2f1a29..35faa203d549 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -709,6 +709,8 @@ scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id)
if (scmi_mailbox_check(np)) {
cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE);
+ if (!cinfo)
+ return -EINVAL;
goto idr_alloc;
}
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-03-25 20:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-09 4:02 [PATCH] firmware: arm_scmi: check return value of idr_find Kangjie Lu
2019-03-23 2:18 ` Kangjie Lu
2019-03-25 11:54 ` Steven Price
2019-03-25 20:48 ` Kangjie Lu [this message]
2019-03-26 11:34 ` Steven Price
2019-04-10 16:31 ` Sudeep Holla
2019-04-10 16:25 ` Sudeep Holla
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=20190325204823.5428-1-kjlu@umn.edu \
--to=kjlu@umn.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pakki001@umn.edu \
--cc=sudeep.holla@arm.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).