ASoC: SOF: Intel: hda: fix index used in inner loop
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tue, 11 May 2021 21:36:59 +0000 (16:36 -0500)
committerMark Brown <broonie@kernel.org>
Wed, 12 May 2021 12:02:47 +0000 (13:02 +0100)
With more warnings than the default, Sparse throws the following
warning:

sound/soc/sof/intel/hda.c:1127:49: error: self-comparison always
evaluates to true
sound/soc/sof/intel/hda.c:1128:49: error: self-comparison always
evaluates to true
sound/soc/sof/intel/hda.c:1129:48: error: self-comparison always
evaluates to true

This looks like an obvious error, with a likely copy-pasted line
leading to the use of the wrong index in an inner loop. One of the
worst single-character bugs in a long time.

This problem was not detected in our tests since in practice SoundWire
platforms only have identical devices per link and the index mistake
did not change the results.

Fixes: 6f5d506d7ff1dq ('ASoC: SOF: Intel: SoundWire: refine ACPI match')
Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210511213707.32958-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda.c

index b00e8fc..5658e4b 100644 (file)
@@ -1069,7 +1069,7 @@ static bool link_slaves_found(struct snd_sof_dev *sdev,
 
                        /* find out how many identical parts are expected */
                        for (k = 0; k < link->num_adr; k++) {
-                               u64 adr2 = link->adr_d[i].adr;
+                               u64 adr2 = link->adr_d[k].adr;
                                unsigned int part_id2, link_id2, mfg_id2;
 
                                mfg_id2 = SDW_MFG_ID(adr2);