parse_thread_groups() is supposed to return -EINVAL if the property
does not exist and -ENODATA if property does not have a value.
However, it is currently assuming it exists and blindly calling
kzalloc_objs() with whatever of_property_count_u32_elems() returns.

Since of_property_count_u32_elems() returns exactly these same error
values in those cases, simply return with the returned error value.

Signed-off-by: John Ogness <[email protected]>
---
 arch/powerpc/kernel/smp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 7a25eaa59e626..58824f5f4c800 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -824,6 +824,8 @@ static int parse_thread_groups(struct device_node *dn,
        int i = 0;
 
        count = of_property_count_u32_elems(dn, "ibm,thread-groups");
+       if (count < 0)
+               return count;
        thread_group_array = kzalloc_objs(u32, count);
        if (!thread_group_array)
                return -ENOMEM;
-- 
2.47.3

Reply via email to