public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: vkoul@kernel.org, yung-chuan.liao@linux.intel.com,
	pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] soundwire: qcom: fix max auto-enumeration devices
Date: Fri, 8 Jul 2022 13:04:53 +0300	[thread overview]
Message-ID: <20220708100453.GM2316@kadam> (raw)
In-Reply-To: <20220708091947.5610-1-srinivas.kandagatla@linaro.org>

On Fri, Jul 08, 2022 at 10:19:47AM +0100, Srinivas Kandagatla wrote:
> Controller only supports up to max of 1-11 device ids via auto-enumeration,
> and it has only those many registers.
> 
> In the existing code, we can protentially cross this boundary and read incorrect
> registers.
> 
> Cc: stable@vger.kernel.org
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: a6e6581942ca ("soundwire: qcom: add auto enumeration support")
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> Thanks to Dan for reporting an overflow issue, which turned out to be
> another issue, where we could read registers that do not belong to
> auto-enumeration devid.
> Either way this fixes both issues, one reported by Dan and other
> incorrect register access.
> 
> Thanks,
> Srini
> 
>  drivers/soundwire/qcom.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index 9df970eeca45..dd1365a44458 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -119,6 +119,8 @@
>  #define MAX_FIFO_RD_RETRY 3
>  #define SWR_OVERFLOW_RETRY_COUNT 30
>  #define SWRM_LINK_STATUS_RETRY_CNT 100
> +/* devid 1 - 11 */
> +#define SWRM_MAX_AUTO_ENUM_DEVICES	11
>  
>  enum {
>  	MASTER_ID_WSA = 1,
> @@ -479,7 +481,7 @@ static int qcom_swrm_enumerate(struct sdw_bus *bus)
>  	int i;
>  	char *buf1 = (char *)&val1, *buf2 = (char *)&val2;
>  
> -	for (i = 1; i <= SDW_MAX_DEVICES; i++) {
> +	for (i = 1; i <= SWRM_MAX_AUTO_ENUM_DEVICES; i++) {

I'm sorry, I don't understand.  Both of these defines are 11 so this
doesn't change anything?

regards,
dan carpenter

>  		/* do not continue if the status is Not Present  */
>  		if (!ctrl->status[i])
>  			continue;
> -- 
> 2.25.1

  reply	other threads:[~2022-07-08 10:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08  9:19 [PATCH] soundwire: qcom: fix max auto-enumeration devices Srinivas Kandagatla
2022-07-08 10:04 ` Dan Carpenter [this message]
2022-07-08 10:11   ` Srinivas Kandagatla

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=20220708100453.GM2316@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /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