Skip to content

Commit acf5631

Browse files
anderssongregkh
authored andcommitted
usb: typec: mux: Fix matching with typec_altmode_desc
In typec_mux_match() "nval" is assigned the number of elements in the "svid" fwnode property, then the variable is used to store the success of the read and finally attempts to loop between 0 and "success" - i.e. not at all - and the code returns indicating that no match was found. Fix this by using a separate variable to track the success of the read, to allow the loop to get a change to find a match. Fixes: 96a6d03 ("usb: typec: mux: Find the muxes by also matching against the device node") Reviewed-by: Heikki Krogerus <[email protected]> Cc: stable <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dcb4b8a commit acf5631

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/usb/typec/mux.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
191191
bool match;
192192
int nval;
193193
u16 *val;
194+
int ret;
194195
int i;
195196

196197
/*
@@ -218,10 +219,10 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
218219
if (!val)
219220
return ERR_PTR(-ENOMEM);
220221

221-
nval = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
222-
if (nval < 0) {
222+
ret = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
223+
if (ret < 0) {
223224
kfree(val);
224-
return ERR_PTR(nval);
225+
return ERR_PTR(ret);
225226
}
226227

227228
for (i = 0; i < nval; i++) {

0 commit comments

Comments
 (0)