pinctrl: zynqmp: Ensure ret is initialised
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Thu, 7 Aug 2025 10:04:04 +0000 (11:04 +0100)
committerMichal Simek <michal.simek@amd.com>
Mon, 25 Aug 2025 14:20:47 +0000 (16:20 +0200)
In zynqmp_pinctrl_prepare_func_groups if called with func->ngroups == 0
then ret will not be assigned to before its value is returned on exit.
Initialise ret to ensure it is always valid.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Link: https://lore.kernel.org/r/20250807-pinctrl_misc-v1-3-eeb564a1b032@linaro.org
Signed-off-by: Michal Simek <michal.simek@amd.com>
drivers/pinctrl/pinctrl-zynqmp.c

index 6fa203a..27dadbf 100644 (file)
@@ -204,7 +204,7 @@ static int zynqmp_pinctrl_prepare_func_groups(u32 fid,
        const char **fgroups;
        char name[MAX_GROUP_NAME_LEN];
        u16 resp[NUM_GROUPS_PER_RESP] = {0};
-       int ret, index, i;
+       int ret = 0, index, i;
 
        fgroups = kcalloc(func->ngroups, sizeof(*fgroups), GFP_KERNEL);
        if (!fgroups)