Skip to content

ASoC: SOF: Intel: add an empty adr_link#5746

Open
bardliao wants to merge 1 commit intothesofproject:topic/sof-devfrom
bardliao:add-empty-link
Open

ASoC: SOF: Intel: add an empty adr_link#5746
bardliao wants to merge 1 commit intothesofproject:topic/sof-devfrom
bardliao:add-empty-link

Conversation

@bardliao
Copy link
Copy Markdown
Collaborator

An empty adr_link is expected to terminate the
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) loop. Allocate link_num + 1 links to add an empty adr_link.

Fixes: 5226d19 ("ASoC: SOF: Intel: use sof_sdw as default SDW machine driver")

An empty adr_link is expected to terminate the
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) loop.
Allocate link_num + 1 links to add an empty adr_link.

Fixes: 5226d19 ("ASoC: SOF: Intel: use sof_sdw as default SDW machine driver")
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an out-of-bounds/unterminated iteration risk when generating the default SoundWire (sof_sdw) machine by ensuring the dynamically-allocated snd_soc_acpi_link_adr array has a zeroed terminator entry (num_adr == 0), matching how asoc_sdw_utils iterates mach_params->links.

Changes:

  • Allocate link_num + 1 snd_soc_acpi_link_adr entries so the final entry is an empty terminator for for (adr_link = mach_params->links; adr_link->num_adr; adr_link++).
  • Add an explanatory comment near the allocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sound/soc/sof/intel/hda.c

link_num = hweight32(link_mask);
links = devm_kcalloc(sdev->dev, link_num, sizeof(*links), GFP_KERNEL);
/* An empty adr_link is need to terminate the adr_link loop */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants