linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soundwire: stream: fix out of boundary access on port properties
@ 2019-05-22 16:24 Srinivas Kandagatla
  2019-05-22 16:37 ` Pierre-Louis Bossart
  2019-05-27  5:04 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2019-05-22 16:24 UTC (permalink / raw)
  To: vkoul
  Cc: sanyog.r.kale, pierre-louis.bossart, alsa-devel, linux-kernel,
	Srinivas Kandagatla

Assigning local iterator to array element and using it again for
indexing would cross the array boundary.
Fix this by directly referring array element without using the local
variable.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/stream.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index d01060dbee96..544925ff0b40 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1406,9 +1406,7 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
 	}
 
 	for (i = 0; i < num_ports; i++) {
-		dpn_prop = &dpn_prop[i];
-
-		if (dpn_prop->num == port_num)
+		if (dpn_prop[i].num == port_num)
 			return &dpn_prop[i];
 	}
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] soundwire: stream: fix out of boundary access on port properties
  2019-05-22 16:24 [PATCH] soundwire: stream: fix out of boundary access on port properties Srinivas Kandagatla
@ 2019-05-22 16:37 ` Pierre-Louis Bossart
  2019-05-27  5:04 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2019-05-22 16:37 UTC (permalink / raw)
  To: Srinivas Kandagatla, vkoul; +Cc: sanyog.r.kale, alsa-devel, linux-kernel



On 5/22/19 11:24 AM, Srinivas Kandagatla wrote:
> Assigning local iterator to array element and using it again for
> indexing would cross the array boundary.
> Fix this by directly referring array element without using the local
> variable.

The change is valid and indeed the code could never work as is. I 
vaguely recall providing this feedback as well in an earlier version.

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>   drivers/soundwire/stream.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index d01060dbee96..544925ff0b40 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1406,9 +1406,7 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
>   	}
>   
>   	for (i = 0; i < num_ports; i++) {
> -		dpn_prop = &dpn_prop[i];
> -
> -		if (dpn_prop->num == port_num)
> +		if (dpn_prop[i].num == port_num)
>   			return &dpn_prop[i];
>   	}
>   
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] soundwire: stream: fix out of boundary access on port properties
  2019-05-22 16:24 [PATCH] soundwire: stream: fix out of boundary access on port properties Srinivas Kandagatla
  2019-05-22 16:37 ` Pierre-Louis Bossart
@ 2019-05-27  5:04 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2019-05-27  5:04 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: sanyog.r.kale, pierre-louis.bossart, alsa-devel, linux-kernel

On 22-05-19, 17:24, Srinivas Kandagatla wrote:
> Assigning local iterator to array element and using it again for
> indexing would cross the array boundary.
> Fix this by directly referring array element without using the local
> variable.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-27  5:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 16:24 [PATCH] soundwire: stream: fix out of boundary access on port properties Srinivas Kandagatla
2019-05-22 16:37 ` Pierre-Louis Bossart
2019-05-27  5:04 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).