Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2655987pxj; Mon, 31 May 2021 07:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9vb7wuIPCB8CQgeFNeixamljWC+IZ6PMBe4TLkgedCp959WhvFvjHmFEEDkgiKwilY0hC X-Received: by 2002:a05:6e02:c6c:: with SMTP id f12mr17732808ilj.163.1622471524548; Mon, 31 May 2021 07:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471524; cv=none; d=google.com; s=arc-20160816; b=pTreS4CXHrv/6ncnL+nqUHk836Ww4WmZEwM708W2/2Gu23xZl3fCH08tG3EBEI4cor eQowRnvorIX7kKb7XgZgaBbWfM9sKC6sPkjqY9uJwzf9NDx7qj8JS8KrIcJOvEnM+r1z YEsH3xwzVaTZyoglh4v7JNL7l6Fg6oW7Xnt7WKz9ru4Q720VV73WsQTh1NV8+cb1Hzin OqfzEB9LBErIl5M/Bqjc04aF5tLYdBy6vWPxwgQHdgx3VIZIq7ghPcFx6gv6ez4K4i1X olXaKlT9BXhniNJU6I8JCES99dpuXHAHmVxHYbHRRoBnrlIvUn5pqbqPvQUA+a8wj75B G9cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w9ZelvGi64F/kE+urpaHAYsh/YGZn0mC+kuT9kF/me4=; b=RSk4xcu6A9MbTDQ+rwqnzHvsummPQ0Y/hL1yO7EQXyGk7Y9Xg/fwknzO9z/PVuUneO OfGL0Sqr1e8Tmy707s+5GWfnVgzfyL5imICfG20PRQ2/vlvCWYVGdyZIRbYR+qdPMdLY AG8HzrfTdo5SFDxlYn4eNHEe1i6d8WYniTDEKZq5c4C5fZLT79ZNAj5WGuu4FnyJRuPK mMulBDvjQ8WDECKbe+Qj0X8QW6uT8B5ayo/dMxQVAWgTm8pPXolgJ+t+EkYpI0zadsZt vpDQcfnQrLOzbYDMx37c4YthtcPCgLHNguWnJug8aDieXV07KvOMNCbOFL2QKWoeLw1H /YpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UbniEEWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si4308753iov.2.2021.05.31.07.31.50; Mon, 31 May 2021 07:32:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UbniEEWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232443AbhEaOcT (ORCPT + 99 others); Mon, 31 May 2021 10:32:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233113AbhEaNy2 (ORCPT ); Mon, 31 May 2021 09:54:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AB81613F4; Mon, 31 May 2021 13:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468022; bh=6F4LA1KYJub7FaLxg+TkDK0L6lJ+/RJtGLAZGeI3SSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UbniEEWDS6y0aEbKe0kHQ7KG5Ov8PsnZ6465A41DPZZeF6mrDYXri7b+jEKrGdqem c0YiffxF+QIma8wOMcfjDMc7+1i2BDdc892ympEUepsXhw+BjnZSS6ab8hIXooD0Q9 G8rj3H5V5Es2KEvMNllFLStU/duhx5/tj1LrT/8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heikki Krogerus , Bjorn Andersson Subject: [PATCH 5.10 088/252] usb: typec: mux: Fix matching with typec_altmode_desc Date: Mon, 31 May 2021 15:12:33 +0200 Message-Id: <20210531130700.967476722@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Andersson commit acf5631c239dfc53489f739c4ad47f490c5181ff upstream. 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: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node") Reviewed-by: Heikki Krogerus Cc: stable Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20210516034730.621461-1-bjorn.andersson@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/mux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -191,6 +191,7 @@ static void *typec_mux_match(struct fwno bool match; int nval; u16 *val; + int ret; int i; /* @@ -218,10 +219,10 @@ static void *typec_mux_match(struct fwno if (!val) return ERR_PTR(-ENOMEM); - nval = fwnode_property_read_u16_array(fwnode, "svid", val, nval); - if (nval < 0) { + ret = fwnode_property_read_u16_array(fwnode, "svid", val, nval); + if (ret < 0) { kfree(val); - return ERR_PTR(nval); + return ERR_PTR(ret); } for (i = 0; i < nval; i++) {