Skip to contentSkip to conversation

extcon: add index increment in find_cable_index_by_name

PATCH In review Tim Bird 1 participant 2 messages Aug 10, 2015 External connector subsystem (extcon)

lore
Share & tools
lore

Tim Bird

author
#0 lore raw

PATCH 1/1 extcon: add index increment in find_cable_index_by_name

This fixes a bug introduced by commit 73b6ecdb93e8 ("extcon: Redefine the unique id of supported external connectors without 'enum extcon' type") which introduced an infinite loop in find_cable_index_by_name. That commit converted the scan from a for loop to a while, but did not increment 'i' anywhere in the loop. If the loop index is not incremented, the function never exits.

This function can never work correctly without this fix.

---
 drivers/extcon/extcon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/extcon/extcon.c +1 -0
index dda1e62..734a9b1 100644
@@ -138,6 +138,7 @@ static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
 			id = i;
 			break;
 		}
+		i++;
 	}
 
 	if (id == EXTCON_NONE)
Signature · 1 line
1.8.2.2
author
#1 lore raw

Never mind...

This is already fixed by commit be052cc8 in mainline.

Sorry for the noise.
-- Tim

Quoted 27 lines · Tim Bird

This fixes a bug introduced by commit 73b6ecdb93e8 ("extcon: Redefine the unique id of supported external connectors without 'enum extcon' type") which introduced an infinite loop in find_cable_index_by_name. That commit converted the scan from a for loop to a while, but did not increment 'i' anywhere in the loop. If the loop index is not incremented, the function never exits.

This function can never work correctly without this fix.

---
 drivers/extcon/extcon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/extcon/extcon.c +1 -0
index dda1e62..734a9b1 100644
@@ -138,6 +138,7 @@ static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
 			id = i;
 			break;
 		}
+		i++;
 	}
 
 	if (id == EXTCON_NONE)