]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: imx: Return NULL if no group is matched and found
authorHui Wang <hui.wang@canonical.com>
Thu, 27 Mar 2025 03:16:00 +0000 (11:16 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 15 Apr 2025 07:42:15 +0000 (09:42 +0200)
Currently if no group is matched and found, this function will return
the last grp to the caller, this is not expected, it is supposed to
return NULL in this case.

Fixes: e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for managing groups")
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/20250327031600.99723-1-hui.wang@canonical.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/freescale/pinctrl-imx.c

index 842a1e6cbfc41a2d108f90f4167dd94c457ea723..18de31328540458b7f7e8e2e539a39d61829deb9 100644 (file)
@@ -37,16 +37,16 @@ static inline const struct group_desc *imx_pinctrl_find_group_by_name(
                                struct pinctrl_dev *pctldev,
                                const char *name)
 {
-       const struct group_desc *grp = NULL;
+       const struct group_desc *grp;
        int i;
 
        for (i = 0; i < pctldev->num_groups; i++) {
                grp = pinctrl_generic_get_group(pctldev, i);
                if (grp && !strcmp(grp->grp.name, name))
-                       break;
+                       return grp;
        }
 
-       return grp;
+       return NULL;
 }
 
 static void imx_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,