kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ 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] 7+ messages in thread

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

Thread overview: 7+ 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-11 10:51 ` Vinod Koul
2017-12-11 10:45   ` Sriram Periyasamy
2017-12-11 11:20 ` Andy Shevchenko
2017-12-11 11:33   ` Dan Carpenter
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

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).