Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2733835pxj; Mon, 31 May 2021 09:22:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylJdnUb/UnNn1Lq/tVMFWnYg1yem2u9mzMEjV5zpEvFsQkwW6RUuLzhLTlPcHSYuBgsB6R X-Received: by 2002:aa7:d9d8:: with SMTP id v24mr3552771eds.15.1622478151399; Mon, 31 May 2021 09:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478151; cv=none; d=google.com; s=arc-20160816; b=rHafcsv9Pkiz7B5ICY4tOs13lsD42YMxCNLcnfSyFPpkqibgvqOaXIZ7/aAo4peiuw BReF0LfdrqoQqLtAoO6Rba2QULQ9YfqmogUTYz0HV4qhKKlREhwbyo1TlSZR8TAkxCoK 9jQwz2PqSYPr7rtCFiw3X95IxEXirvqGacdC79AL1bAPOJOIHhu5BaIWMURTHjbgv6Vg 2gtrINljFKdiKr88iwjo2PoWRSpsi5bTvUGPZWUfX5/ZrvjaDMTbZlgOEYCxTXjBvTjy Wxp+olJUwnsVPzHl0iKYVprhdGHZJXRnx7bGF1o4wNuR9pbV62tdicRMou+2gdYLfQUo S12A== 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=j2Z933qo8b0pwtDd99HygYU1GCzOyDlcGfoD05huTncbl4daF994HivSP8tFkomoi8 qRnszIbY2Pj2VXssgDFKzlWlq+kfdIyYA/lIsa1mg/mEC5CdgmYrGlQwxV7C1N0gKVkP uQMI84/YqjpaxA/rPQ/tePk3amGLq5L+JuxAGM/uFnTA1vATYB0KASq2jyQRJ14Xr1Y0 prlWP9WZq1w9jg7JNQ9+4LwvLWZd2cPuaYJWmT8x2H9BQjKEXralIBjylCKnh1witsj5 uJMvq57knbfp3xcnpkKllGtSvU8du2PGsdMxAXJKJYZphZHoqUal41BJ83GFCkIdH1AF +vpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lijcUevi; 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 t21si12325428edd.145.2021.05.31.09.22.07; Mon, 31 May 2021 09:22:31 -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=lijcUevi; 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 S233528AbhEaQUm (ORCPT + 99 others); Mon, 31 May 2021 12:20:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:37858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233330AbhEaOlX (ORCPT ); Mon, 31 May 2021 10:41:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E6D761374; Mon, 31 May 2021 13:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469193; bh=6F4LA1KYJub7FaLxg+TkDK0L6lJ+/RJtGLAZGeI3SSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lijcUevikvNeKwSILYoF6aPeHjYhVk8zV0aC6O43uh+xMANhYCJkT4d/JFHp1RbHx qdeVYYzTYZYiULMLwXgfe+/1ZBwav6jjWUJALFM1e52I2BHln2hVzJvUtt6HaaDefr zWlnK/6ds1X92Emg4c3As4FGQjn2kglGa4JGgZnQ= 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.12 105/296] usb: typec: mux: Fix matching with typec_altmode_desc Date: Mon, 31 May 2021 15:12:40 +0200 Message-Id: <20210531130707.466835594@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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++) {