Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: ipc4-control: Return on error in sof_ipc4_widget_kcontrol_setup()

The patch adding the bytes control support moved the error check outside
of the list_for_each_entry() which was not correct as at the end of the
list_for_each_entry() the scontrol will no longer point where the error
happened, but it to the list head.

Restore the original logic and return on the first error with the error
code.

Fixes: a062c8899fed ("ASoC: SOF: ipc4-control: Add support for bytes control get and put")
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/alsa-devel/6be945d2-40cb-46fb-67ba-ed3a19cddfa4@linux.intel.com/T/#t
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230321145651.9118-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Peter Ujfalusi and committed by
Mark Brown
1c12e032 1d78e193

+8 -5
+8 -5
sound/soc/sof/ipc4-control.c
··· 429 429 default: 430 430 break; 431 431 } 432 + 433 + if (ret < 0) { 434 + dev_err(sdev->dev, 435 + "kcontrol %d set up failed for widget %s\n", 436 + scontrol->comp_id, swidget->widget->name); 437 + return ret; 438 + } 432 439 } 433 440 } 434 441 435 - if (ret < 0) 436 - dev_err(sdev->dev, "kcontrol %d set up failed for widget %s\n", 437 - scontrol->comp_id, swidget->widget->name); 438 - 439 - return ret; 442 + return 0; 440 443 } 441 444 442 445 static int