All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-08 11:54 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2017-12-08 11:54 UTC (permalink / raw)
  To: Liam Girdwood, Sriram Periyasamy
  Cc: alsa-devel, Jani Nikula, Pankaj Bharadiya, Guneshwor Singh,
	Takashi Iwai, Vinod Koul, kernel-janitors, Mark Brown,
	Senthilnathan Veppur, Andy Shevchenko, Subhransu S. Prusty

I get a Smatch warning here:

    sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
    error: testing array offset 'j' after use.

The code is harmless, but the checker is right that we should swap these
two conditions so we verify that the offset is within bounds before we
use it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index afa557a1c031..54f9bd630f4f 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
 		rate = channels * bps * fs;
 
 		/* check if the rate is added already to the given SSP's sclk */
-		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
-				(j < SKL_MAX_CLK_RATES); j++) {
+		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
+			    (sclk[id].rate_cfg[j].rate != 0); j++) {
 			if (sclk[id].rate_cfg[j].rate = rate) {
 				present = true;
 				break;

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

* [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-08 11:54 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2017-12-08 11:54 UTC (permalink / raw)
  To: Liam Girdwood, Sriram Periyasamy
  Cc: alsa-devel, Jani Nikula, Pankaj Bharadiya, Guneshwor Singh,
	Takashi Iwai, Vinod Koul, kernel-janitors, Mark Brown,
	Senthilnathan Veppur, Andy Shevchenko, Subhransu S. Prusty

I get a Smatch warning here:

    sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
    error: testing array offset 'j' after use.

The code is harmless, but the checker is right that we should swap these
two conditions so we verify that the offset is within bounds before we
use it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index afa557a1c031..54f9bd630f4f 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
 		rate = channels * bps * fs;
 
 		/* check if the rate is added already to the given SSP's sclk */
-		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
-				(j < SKL_MAX_CLK_RATES); j++) {
+		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
+			    (sclk[id].rate_cfg[j].rate != 0); j++) {
 			if (sclk[id].rate_cfg[j].rate == rate) {
 				present = true;
 				break;

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
  2017-12-11 10:51   ` Vinod Koul
@ 2017-12-11 10:45     ` Sriram Periyasamy
  -1 siblings, 0 replies; 14+ messages in thread
From: Sriram Periyasamy @ 2017-12-11 10:33 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Dan Carpenter, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Subhransu S. Prusty, Jani Nikula, Guneshwor Singh,
	Pankaj Bharadiya, Andy Shevchenko, Senthilnathan Veppur,
	alsa-devel, kernel-janitors

On Mon, Dec 11, 2017 at 04:09:44PM +0530, Vinod Koul wrote:
> On Fri, Dec 08, 2017 at 02:54:25PM +0300, Dan Carpenter wrote:
> > I get a Smatch warning here:
> > 
> >     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
> >     error: testing array offset 'j' after use.
> > 
> > The code is harmless, but the checker is right that we should swap these
> > two conditions so we verify that the offset is within bounds before we
> > use it.
> 
> Acked-By: Vinod Koul <vinod.koul@intel.com>

Reviewed-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>

> 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
> > index afa557a1c031..54f9bd630f4f 100644
> > --- a/sound/soc/intel/skylake/skl-nhlt.c
> > +++ b/sound/soc/intel/skylake/skl-nhlt.c
> > @@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
> >  		rate = channels * bps * fs;
> >  
> >  		/* check if the rate is added already to the given SSP's sclk */
> > -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> > -				(j < SKL_MAX_CLK_RATES); j++) {
> > +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> > +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
> >  			if (sclk[id].rate_cfg[j].rate == rate) {
> >  				present = true;
> >  				break;
> 
> -- 
> ~Vinod

-- 

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
  2017-12-08 11:54 ` Dan Carpenter
@ 2017-12-11 10:51   ` Vinod Koul
  -1 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2017-12-11 10:39 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Liam Girdwood, Sriram Periyasamy, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Subhransu S. Prusty, Jani Nikula, Guneshwor Singh,
	Pankaj Bharadiya, Andy Shevchenko, Senthilnathan Veppur,
	alsa-devel, kernel-janitors

On Fri, Dec 08, 2017 at 02:54:25PM +0300, Dan Carpenter wrote:
> I get a Smatch warning here:
> 
>     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
>     error: testing array offset 'j' after use.
> 
> The code is harmless, but the checker is right that we should swap these
> two conditions so we verify that the offset is within bounds before we
> use it.

Acked-By: Vinod Koul <vinod.koul@intel.com>

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
> index afa557a1c031..54f9bd630f4f 100644
> --- a/sound/soc/intel/skylake/skl-nhlt.c
> +++ b/sound/soc/intel/skylake/skl-nhlt.c
> @@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
>  		rate = channels * bps * fs;
>  
>  		/* check if the rate is added already to the given SSP's sclk */
> -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> -				(j < SKL_MAX_CLK_RATES); j++) {
> +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
>  			if (sclk[id].rate_cfg[j].rate == rate) {
>  				present = true;
>  				break;

-- 
~Vinod

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-11 10:45     ` Sriram Periyasamy
  0 siblings, 0 replies; 14+ messages in thread
From: Sriram Periyasamy @ 2017-12-11 10:45 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Dan Carpenter, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Subhransu S. Prusty, Jani Nikula, Guneshwor Singh,
	Pankaj Bharadiya, Andy Shevchenko, Senthilnathan Veppur,
	alsa-devel, kernel-janitors

On Mon, Dec 11, 2017 at 04:09:44PM +0530, Vinod Koul wrote:
> On Fri, Dec 08, 2017 at 02:54:25PM +0300, Dan Carpenter wrote:
> > I get a Smatch warning here:
> > 
> >     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
> >     error: testing array offset 'j' after use.
> > 
> > The code is harmless, but the checker is right that we should swap these
> > two conditions so we verify that the offset is within bounds before we
> > use it.
> 
> Acked-By: Vinod Koul <vinod.koul@intel.com>

Reviewed-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>

> 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
> > index afa557a1c031..54f9bd630f4f 100644
> > --- a/sound/soc/intel/skylake/skl-nhlt.c
> > +++ b/sound/soc/intel/skylake/skl-nhlt.c
> > @@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
> >  		rate = channels * bps * fs;
> >  
> >  		/* check if the rate is added already to the given SSP's sclk */
> > -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> > -				(j < SKL_MAX_CLK_RATES); j++) {
> > +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> > +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
> >  			if (sclk[id].rate_cfg[j].rate = rate) {
> >  				present = true;
> >  				break;
> 
> -- 
> ~Vinod

-- 

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-11 10:51   ` Vinod Koul
  0 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2017-12-11 10:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Liam Girdwood, Sriram Periyasamy, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Subhransu S. Prusty, Jani Nikula, Guneshwor Singh,
	Pankaj Bharadiya, Andy Shevchenko, Senthilnathan Veppur,
	alsa-devel, kernel-janitors

On Fri, Dec 08, 2017 at 02:54:25PM +0300, Dan Carpenter wrote:
> I get a Smatch warning here:
> 
>     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
>     error: testing array offset 'j' after use.
> 
> The code is harmless, but the checker is right that we should swap these
> two conditions so we verify that the offset is within bounds before we
> use it.

Acked-By: Vinod Koul <vinod.koul@intel.com>

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
> index afa557a1c031..54f9bd630f4f 100644
> --- a/sound/soc/intel/skylake/skl-nhlt.c
> +++ b/sound/soc/intel/skylake/skl-nhlt.c
> @@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
>  		rate = channels * bps * fs;
>  
>  		/* check if the rate is added already to the given SSP's sclk */
> -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> -				(j < SKL_MAX_CLK_RATES); j++) {
> +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
>  			if (sclk[id].rate_cfg[j].rate = rate) {
>  				present = true;
>  				break;

-- 
~Vinod

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
  2017-12-08 11:54 ` Dan Carpenter
@ 2017-12-11 11:20   ` Andy Shevchenko
  -1 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2017-12-11 11:20 UTC (permalink / raw)
  To: Dan Carpenter, Liam Girdwood, Sriram Periyasamy
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, Subhransu S. Prusty,
	Jani Nikula, Guneshwor Singh, Pankaj Bharadiya,
	Senthilnathan Veppur, Vinod Koul, alsa-devel, kernel-janitors

On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> I get a Smatch warning here:
> 
>     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
>     error: testing array offset 'j' after use.
> 
> The code is harmless, but the checker is right that we should swap
> these
> two conditions so we verify that the offset is within bounds before we
> use it.

> -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> -				(j < SKL_MAX_CLK_RATES); j++) {
> +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
>  			if (sclk[id].rate_cfg[j].rate = rate) {
>  				present = true;
>  				break;

I would rather remove also redundant parens and move the condition into
the loop.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-11 11:20   ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2017-12-11 11:20 UTC (permalink / raw)
  To: Dan Carpenter, Liam Girdwood, Sriram Periyasamy
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, Subhransu S. Prusty,
	Jani Nikula, Guneshwor Singh, Pankaj Bharadiya,
	Senthilnathan Veppur, Vinod Koul, alsa-devel, kernel-janitors

On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> I get a Smatch warning here:
> 
>     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
>     error: testing array offset 'j' after use.
> 
> The code is harmless, but the checker is right that we should swap
> these
> two conditions so we verify that the offset is within bounds before we
> use it.

> -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> -				(j < SKL_MAX_CLK_RATES); j++) {
> +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
>  			if (sclk[id].rate_cfg[j].rate == rate) {
>  				present = true;
>  				break;

I would rather remove also redundant parens and move the condition into
the loop.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
  2017-12-11 11:20   ` Andy Shevchenko
@ 2017-12-11 11:33     ` Dan Carpenter
  -1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2017-12-11 11:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, Jani Nikula, Sriram Periyasamy, Guneshwor Singh,
	Takashi Iwai, Liam Girdwood, Vinod Koul, kernel-janitors,
	Mark Brown, Pankaj Bharadiya, Senthilnathan Veppur,
	Subhransu S. Prusty

On Mon, Dec 11, 2017 at 01:20:23PM +0200, Andy Shevchenko wrote:
> On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> > I get a Smatch warning here:
> > 
> >     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
> >     error: testing array offset 'j' after use.
> > 
> > The code is harmless, but the checker is right that we should swap
> > these
> > two conditions so we verify that the offset is within bounds before we
> > use it.
> 
> > -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> > -				(j < SKL_MAX_CLK_RATES); j++) {
> > +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> > +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
> >  			if (sclk[id].rate_cfg[j].rate = rate) {
> >  				present = true;
> >  				break;
> 
> I would rather remove also redundant parens and move the condition into
> the loop.

I didn't like the way the code was written either but it's impossible
to know how much change people are going to accept.  Even though I think
that extra parenthesis shouldn't have been there, the original author
felt they helped, so I try to be accomodating...

Anyway, I can resend.

regards,
dan carpenter


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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-11 11:33     ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2017-12-11 11:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, Jani Nikula, Sriram Periyasamy, Guneshwor Singh,
	Takashi Iwai, Liam Girdwood, Vinod Koul, kernel-janitors,
	Mark Brown, Pankaj Bharadiya, Senthilnathan Veppur,
	Subhransu S. Prusty

On Mon, Dec 11, 2017 at 01:20:23PM +0200, Andy Shevchenko wrote:
> On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> > I get a Smatch warning here:
> > 
> >     sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
> >     error: testing array offset 'j' after use.
> > 
> > The code is harmless, but the checker is right that we should swap
> > these
> > two conditions so we verify that the offset is within bounds before we
> > use it.
> 
> > -		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
> > -				(j < SKL_MAX_CLK_RATES); j++) {
> > +		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
> > +			    (sclk[id].rate_cfg[j].rate != 0); j++) {
> >  			if (sclk[id].rate_cfg[j].rate == rate) {
> >  				present = true;
> >  				break;
> 
> I would rather remove also redundant parens and move the condition into
> the loop.

I didn't like the way the code was written either but it's impossible
to know how much change people are going to accept.  Even though I think
that extra parenthesis shouldn't have been there, the original author
felt they helped, so I try to be accomodating...

Anyway, I can resend.

regards,
dan carpenter

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
  2017-12-11 11:33     ` Dan Carpenter
@ 2017-12-11 11:54       ` Andy Shevchenko
  -1 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2017-12-11 11:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Liam Girdwood, Sriram Periyasamy, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Subhransu S. Prusty, Jani Nikula, Guneshwor Singh,
	Pankaj Bharadiya, Senthilnathan Veppur, Vinod Koul, alsa-devel,
	kernel-janitors

On Mon, 2017-12-11 at 14:33 +0300, Dan Carpenter wrote:
> On Mon, Dec 11, 2017 at 01:20:23PM +0200, Andy Shevchenko wrote:
> > On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> > > 
> 


> I didn't like the way the code was written either but it's impossible
> to know how much change people are going to accept.  Even though I
> think
> that extra parenthesis shouldn't have been there, the original author
> felt they helped, so I try to be accomodating...
> 
> Anyway, I can resend.

Since Vinod ACKed this change, I'm fine with it.
Consider my comment as JFYI.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning
@ 2017-12-11 11:54       ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2017-12-11 11:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Liam Girdwood, Sriram Periyasamy, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Subhransu S. Prusty, Jani Nikula, Guneshwor Singh,
	Pankaj Bharadiya, Senthilnathan Veppur, Vinod Koul, alsa-devel,
	kernel-janitors

On Mon, 2017-12-11 at 14:33 +0300, Dan Carpenter wrote:
> On Mon, Dec 11, 2017 at 01:20:23PM +0200, Andy Shevchenko wrote:
> > On Fri, 2017-12-08 at 14:54 +0300, Dan Carpenter wrote:
> > > 
> 


> I didn't like the way the code was written either but it's impossible
> to know how much change people are going to accept.  Even though I
> think
> that extra parenthesis shouldn't have been there, the original author
> felt they helped, so I try to be accomodating...
> 
> Anyway, I can resend.

Since Vinod ACKed this change, I'm fine with it.
Consider my comment as JFYI.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Applied "ASoC: Intel: Skylake: Re-order some code to silence a warning" to the asoc tree
  2017-12-08 11:54 ` Dan Carpenter
@ 2017-12-11 12:13   ` Mark Brown
  -1 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2017-12-11 12:13 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mark Brown, Liam Girdwood, Sriram Periyasamy, alsa-devel,
	Jani Nikula, Pankaj Bharadiya, Guneshwor Singh, Takashi Iwai,
	Vinod Koul, kernel-janitors

The patch

   ASoC: Intel: Skylake: Re-order some code to silence a warning

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 87684d338a22d15e47b16ee68f569d74ad1d076e Mon Sep 17 00:00:00 2001
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 8 Dec 2017 14:54:25 +0300
Subject: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning

I get a Smatch warning here:

    sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
    error: testing array offset 'j' after use.

The code is harmless, but the checker is right that we should swap these
two conditions so we verify that the offset is within bounds before we
use it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-nhlt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index ca5dc2be7b68..bde7f40f29f5 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -322,8 +322,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
 		rate = channels * bps * fs;
 
 		/* check if the rate is added already to the given SSP's sclk */
-		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
-				(j < SKL_MAX_CLK_RATES); j++) {
+		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
+			    (sclk[id].rate_cfg[j].rate != 0); j++) {
 			if (sclk[id].rate_cfg[j].rate = rate) {
 				present = true;
 				break;
-- 
2.15.1


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

* Applied "ASoC: Intel: Skylake: Re-order some code to silence a warning" to the asoc tree
@ 2017-12-11 12:13   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2017-12-11 12:13 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mark Brown, Liam Girdwood, Sriram Periyasamy, alsa-devel,
	Jani Nikula, Pankaj Bharadiya, Guneshwor Singh, Takashi Iwai,
	Vinod Koul, kernel-janitors

The patch

   ASoC: Intel: Skylake: Re-order some code to silence a warning

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 87684d338a22d15e47b16ee68f569d74ad1d076e Mon Sep 17 00:00:00 2001
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 8 Dec 2017 14:54:25 +0300
Subject: [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning

I get a Smatch warning here:

    sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
    error: testing array offset 'j' after use.

The code is harmless, but the checker is right that we should swap these
two conditions so we verify that the offset is within bounds before we
use it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-nhlt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index ca5dc2be7b68..bde7f40f29f5 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -322,8 +322,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
 		rate = channels * bps * fs;
 
 		/* check if the rate is added already to the given SSP's sclk */
-		for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
-				(j < SKL_MAX_CLK_RATES); j++) {
+		for (j = 0; (j < SKL_MAX_CLK_RATES) &&
+			    (sclk[id].rate_cfg[j].rate != 0); j++) {
 			if (sclk[id].rate_cfg[j].rate == rate) {
 				present = true;
 				break;
-- 
2.15.1


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

end of thread, other threads:[~2017-12-11 12:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08 11:54 [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning Dan Carpenter
2017-12-08 11:54 ` Dan Carpenter
2017-12-11 10:39 ` Vinod Koul
2017-12-11 10:51   ` Vinod Koul
2017-12-11 10:33   ` Sriram Periyasamy
2017-12-11 10:45     ` Sriram Periyasamy
2017-12-11 11:20 ` Andy Shevchenko
2017-12-11 11:20   ` Andy Shevchenko
2017-12-11 11:33   ` Dan Carpenter
2017-12-11 11:33     ` Dan Carpenter
2017-12-11 11:54     ` Andy Shevchenko
2017-12-11 11:54       ` Andy Shevchenko
2017-12-11 12:13 ` Applied "ASoC: Intel: Skylake: Re-order some code to silence a warning" to the asoc tree Mark Brown
2017-12-11 12:13   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.