parse_reg() decodes the index out of the ggs%u/pggs%u parameter names the
driver registers itself, so the conversion can't really fail.

We define __must_check as empty currently, so the __must_check on
kstrtouint() doesn't catch this, but it will once we change the
definition, so prepare for that.

Signed-off-by: Ahmad Fatoum <[email protected]>
---
 arch/arm/mach-zynqmp/firmware-zynqmp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-zynqmp/firmware-zynqmp.c 
b/arch/arm/mach-zynqmp/firmware-zynqmp.c
index 039a46e76759..d21e2c1137f1 100644
--- a/arch/arm/mach-zynqmp/firmware-zynqmp.c
+++ b/arch/arm/mach-zynqmp/firmware-zynqmp.c
@@ -712,7 +712,11 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_get_eemi_ops);
 static bool parse_reg(const char *reg, unsigned *idx)
 {
        bool pggs = reg[0] == 'p';
-       kstrtouint(reg + pggs + sizeof("ggs") - 1, 10, idx);
+
+       /* the names are registered by this driver as ggs%u and pggs%u */
+       if (WARN_ON(kstrtouint(reg + pggs + sizeof("ggs") - 1, 10, idx)))
+               *idx = 0;
+
        return pggs;
 }
 
-- 
2.47.3


Reply via email to