public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Jun Li <jun.li@nxp.com>, Hans de Goede <hdegoede@redhat.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: typec: mux: Fix matching with typec_altmode_desc
Date: Mon, 17 May 2021 12:02:07 +0300	[thread overview]
Message-ID: <YKIxDz/vqXzS5EtO@kuha.fi.intel.com> (raw)
In-Reply-To: <20210516034730.621461-1-bjorn.andersson@linaro.org>

On Sat, May 15, 2021 at 08:47:30PM -0700, Bjorn Andersson wrote:
> 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 <bjorn.andersson@linaro.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/mux.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> 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++) {
> -- 
> 2.29.2

thanks,

-- 
heikki

  reply	other threads:[~2021-05-17  9:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16  3:47 [PATCH] usb: typec: mux: Fix matching with typec_altmode_desc Bjorn Andersson
2021-05-17  9:02 ` Heikki Krogerus [this message]
2021-05-17  9:13 ` Andy Shevchenko
2021-05-17 15:14   ` Bjorn Andersson
2021-05-17 15:37     ` Andy Shevchenko
2021-05-17 15:44       ` Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKIxDz/vqXzS5EtO@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox