From patchwork Mon May 31 13:12:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 450501 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp851058jao; Mon, 31 May 2021 06:54:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXk031ofMHsI9PpThtz52TAkT4OjeDvSfcwcM1osihZsrJC7Vx2aMQw0Mz4qLA63UrUj5L X-Received: by 2002:a02:b90b:: with SMTP id v11mr20566270jan.1.1622469290002; Mon, 31 May 2021 06:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469289; cv=none; d=google.com; s=arc-20160816; b=FCZQvMcaRMSJgaO+eVRqIIyz70OD/qyar7rp7NpUEHFFjIXsv+ffBjQ0iwDcVkUTyN 79QYvTThR3tveKbXU3UIP19h6g7iHaL96M+xYQNpVhbAAaOl0pa7cibViXBqi77+LQMM gqMxtO/M6WGjWnad59eg9KepAiLs5i/Y9TCtAtn0Jj2O9YixxYYVh1s2KqKK9TT8dgTk eOJBACbnMTfHqOgV3SehSEG+kxByMLCf0Ml1bvhGs3Rtk9hXtcDPd5t8pUXeoqrrupBR g5Vt5Jn9SGr4Iefib9V5iIC48n9oxqvrpFpUyh2jMJra7CkQig9dK8SJAWQmSqvORFHG jfWg== 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=O23ACu+5ZCz43jc9OrsAhZILTjLCT/T9dDFGzjE7ahjRSs4v26wEZXctpdoF7VvrdS WdBubWyXVeU5S1Hmc4lKdwZXUFQ/Xs2yZllrcfCMkTrMrLaENX+RQ39Lx+D8XNK9qAwf 7DC3J1w13Yrvyz5wVsBSBUVZ+P8a1J2u9gxxIpQc0HYmoQ4NX0V3GSG2MCJZQI/pLzNy CvMIEWdag3iXBekj+2X3GfEwkXEjN65eR3KGfTiFQepZEE0Op7euZZW99rniGQkYtzYr JXIHe4lBGqUB4jNriOyOaC4DVRK9LV24mJRKEIHBXaFP+2uguNazUlup0JsfSIsuU/QE YiDg== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 n14si8122176ili.28.2021.05.31.06.54.48; Mon, 31 May 2021 06:54:49 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S232617AbhEaN40 (ORCPT + 12 others); Mon, 31 May 2021 09:56:26 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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++) {