Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83013edc authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Lee Jones
Browse files

BACKPORT: 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.

Bug: 254441685
Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node")
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20210516034730.621461-1-bjorn.andersson@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit acf5631c239dfc53489f739c4ad47f490c5181ff)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I15e90521b1956718ee3c10d1bfee48a66d9d9fe7
parent cdacf701
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
	bool match;
	int nval;
	u16 *val;
	int ret;
	int i;

	if (!con->fwnode) {
@@ -223,10 +224,10 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
	if (!val)
		return ERR_PTR(-ENOMEM);

	nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval);
	if (nval < 0) {
	ret = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval);
	if (ret < 0) {
		kfree(val);
		return ERR_PTR(nval);
		return ERR_PTR(ret);
	}

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