summaryrefslogtreecommitdiff
path: root/drivers/firmware/ti_sci.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@kernel.org>2019-06-25 04:06:15 +0300
committerStephen Boyd <sboyd@kernel.org>2019-06-25 04:11:41 +0300
commit0b88bc9292515550b4f7b30ac7d7ecd80f5bc1aa (patch)
treec1ff4ae81bedbd4c7a151639f30114b943b057f4 /drivers/firmware/ti_sci.c
parent0af69227ed9fc4ac62f8542e52aba98fc2c7945b (diff)
downloadlinux-0b88bc9292515550b4f7b30ac7d7ecd80f5bc1aa.tar.xz
clk: ti: Use int to check return value from of_property_count_elems_of_size()
This function can return a negative number when it fails, but res->sets is at most a u16 which can't hold that negative number. Let's store the result into an int, ret, and then assign that to res->sets when it works to avoid this logical impossibility. Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/firmware/ti_sci.c')
-rw-r--r--drivers/firmware/ti_sci.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index b417cef35769..7696c692ad5a 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2402,12 +2402,13 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
if (!res)
return ERR_PTR(-ENOMEM);
- res->sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop,
- sizeof(u32));
- if (res->sets < 0) {
+ ret = of_property_count_elems_of_size(dev_of_node(dev), of_prop,
+ sizeof(u32));
+ if (ret < 0) {
dev_err(dev, "%s resource type ids not available\n", of_prop);
- return ERR_PTR(res->sets);
+ return ERR_PTR(ret);
}
+ res->sets = ret;
res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc),
GFP_KERNEL);