Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: core: Ensure disabled devices are skipped without aborting

The loop searching for a matching device based on its compatible
string is aborted when a matching disabled device is found.
This abort prevents to add devices as soon as one disabled device
is found.

Continue searching for an other device instead of aborting on the
first disabled one fixes the issue.

Fixes: 22380b65dc70 ("mfd: mfd-core: Ensure disabled devices are ignored without error")
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/528425d6472176bb1d02d79596b51f8c28a551cc.1692376361.git.christophe.leroy@csgroup.eu
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Herve Codina and committed by
Lee Jones
7ba7bdef 0202e408

+12 -5
+12 -5
drivers/mfd/mfd-core.c
··· 146 146 struct platform_device *pdev; 147 147 struct device_node *np = NULL; 148 148 struct mfd_of_node_entry *of_entry, *tmp; 149 + bool disabled = false; 149 150 int ret = -ENOMEM; 150 151 int platform_id; 151 152 int r; ··· 184 183 if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { 185 184 for_each_child_of_node(parent->of_node, np) { 186 185 if (of_device_is_compatible(np, cell->of_compatible)) { 187 - /* Ignore 'disabled' devices error free */ 186 + /* Skip 'disabled' devices */ 188 187 if (!of_device_is_available(np)) { 189 - of_node_put(np); 190 - ret = 0; 191 - goto fail_alias; 188 + disabled = true; 189 + continue; 192 190 } 193 191 194 192 ret = mfd_match_of_node_to_dev(pdev, np, cell); ··· 197 197 if (ret) 198 198 goto fail_alias; 199 199 200 - break; 200 + goto match; 201 201 } 202 202 } 203 203 204 + if (disabled) { 205 + /* Ignore 'disabled' devices error free */ 206 + ret = 0; 207 + goto fail_alias; 208 + } 209 + 210 + match: 204 211 if (!pdev->dev.of_node) 205 212 pr_warn("%s: Failed to locate of_node [id: %d]\n", 206 213 cell->name, platform_id);