From patchwork Sun May 16 03:47:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 439831 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp1581753jam; Sat, 15 May 2021 20:48:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqOAzT9QInFNv4RfH2y00ozTEhYkiqdmj3hR0XtHTUjDIuuyXn/LLf6wVMwDQ8kOAuDhd4 X-Received: by 2002:a17:906:857:: with SMTP id f23mr3770121ejd.64.1621136880847; Sat, 15 May 2021 20:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621136880; cv=none; d=google.com; s=arc-20160816; b=Z1K6aWoyG7g89m7oNR1f3bkIqMhYYbG9CyuCaxnIWz+yhO9rSCPQVWfVlOS/MM38zK MMUWANS4QUFMjXkkv7fx/QjhTtQ6C8qbdNF50bUqBYSAV3yuGNXrRnn/X+zpF0CRmvWY MEOZH9bx9EzChprwoQP/SuFRX4BMGvQq6jbh/ZzASrLeTl3PFYT+gk2Bn47AInsRdB6F QwQRwUHjJGG30CD08M+mXRDT9+CQzlISk7hkEx86c//EQMls9e9laTiGTHfTKGwwh3Tp lQ2vK0/1rgQykmYOsPRcpvLWTKqTjqWslxVVwCCWlokK3fJvM5NML653asLyp5mnAiPv 5Ssg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=NdBNcSQ1fL9YYvu0gmDFkHR89r/K55hXfYPZOrq9QCs=; b=FOKB9Q+ANaA/Uzl940shH5j0Y6MSRljfvH68k65w5PEPDbqQwDd6PnMJrX6vktPnpX Erum5MC3TOucD3Xct64k7EMCJ4mTgwGUYRm7APmvw4yNXOZDx1H+2SQUkrXsGQrN+ven dFnt4zftTNh7lHZik81UH+Pf1m1ov3+7nTMRsJ/pTEXg8sxQRfDJQ73YmjWwELoFm1lY lYBb9gQh+muNsZgGr99L9MgVWL22JB7T3cYTnSq4TYj5CBP3iL9/V/Uh1ux4+FyNJ0JL QoKFwd1sI+OTf/e0sPejLTjq/OnYbT6Lmvc4fviVm3o39v5zrUR+SQz9HJzaow0ynXS0 z/vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qfgZxKKQ; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec2si10344493ejb.189.2021.05.15.20.48.00; Sat, 15 May 2021 20:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-usb-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=@linaro.org header.s=google header.b=qfgZxKKQ; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232289AbhEPDtD (ORCPT + 4 others); Sat, 15 May 2021 23:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232158AbhEPDtD (ORCPT ); Sat, 15 May 2021 23:49:03 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E837C061573 for ; Sat, 15 May 2021 20:47:48 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 69-20020a9d0a4b0000b02902ed42f141e1so2788421otg.2 for ; Sat, 15 May 2021 20:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NdBNcSQ1fL9YYvu0gmDFkHR89r/K55hXfYPZOrq9QCs=; b=qfgZxKKQXKOKsW/GDWCLAyrQduY+tQL7sbUY1svUl02N2kFG/M31drqyoWvlFPfPKC I/7I0e/wtJOHt5xAIAmCFF0A2eXsqKUdSn6dFo0uH2+pkJOWFPMIlBfZDt/JmDFSHXl3 wTSg6B4U82paFC2hJx5xJQA4kBX5bNS8aVHoNK+0nxQwR1uXXm9S5PDR6apMWY+eslyx CLi34rT0b6vfiGmKT36j5EaN0kNU3oljL6VQBtHt4or3HbBx8D4aCSmBlcqNkw81oDCF n/qdQnIMoW2pe1b/lYYnSEZzRdYTHCqhQo8uap1jsuvIgycYz35xHZiXqhcTbHDUK1MW 8V4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NdBNcSQ1fL9YYvu0gmDFkHR89r/K55hXfYPZOrq9QCs=; b=mEnakF9bNGWHqz1fKuiemVCTbkGKE+rTTmUCsSiubD4H5QuKJeu6fjppKeEEMhXA5E 7V1W26i9vBoE28K/B0ZptFqKpzZZnns9R7aq8DGM/LC+85ENnKSE88CzgMaFX8NqOejn 0nIAW/wRCA7LIOtsJqebYE1b5cYaMVwRLHgnkJL1/ywTDLJ9ildI12/fHSiWBS+9CQ4o g5jn6OyclV048GK+3rGaVgXu0qUskntgHL1/kaVjS+w6+k5+TYSs8EN3gE8sZ9HUqHC9 VLJIL2wgOVGATeT93SePOOinMt8Ilf7DkFrwXQCD6WEaqw7Upx/DFBxWb27JRHL79nmD B/Hw== X-Gm-Message-State: AOAM530OC7YuBZh6xYM814s4m16MGAH+Ut7dtPP3tntpfk1qNg7qTT7v QCTcSZ4h2fy6hN1ZwrBrL7447g== X-Received: by 2002:a05:6830:44f:: with SMTP id d15mr7395709otc.369.1621136867718; Sat, 15 May 2021 20:47:47 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id q1sm2403157otc.21.2021.05.15.20.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 20:47:47 -0700 (PDT) From: Bjorn Andersson To: Heikki Krogerus , Greg Kroah-Hartman , Andy Shevchenko , Jun Li , Hans de Goede Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: typec: mux: Fix matching with typec_altmode_desc Date: Sat, 15 May 2021 20:47:30 -0700 Message-Id: <20210516034730.621461-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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") Signed-off-by: Bjorn Andersson --- drivers/usb/typec/mux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.29.2 Reviewed-by: Heikki Krogerus diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 9da22ae3006c..8514bec7e1b8 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -191,6 +191,7 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id, bool match; int nval; u16 *val; + int ret; int i; /* @@ -218,10 +219,10 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id, 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++) {