Skip to content

ASoC: amd: acp: Fix possible deadlock#5304

Merged
bardliao merged 1 commit intothesofproject:topic/sof-devfrom
dbaluta:fix_deadlock_amd
Jan 23, 2025
Merged

ASoC: amd: acp: Fix possible deadlock#5304
bardliao merged 1 commit intothesofproject:topic/sof-devfrom
dbaluta:fix_deadlock_amd

Conversation

@dbaluta
Copy link
Collaborator

@dbaluta dbaluta commented Jan 22, 2025

On error path, function acp_i2s_set_tdm_slot returns without releasing the lock and this could result in potential deadlocks in the future.

Error reported by sparse:
sound/soc/amd/acp/acp-i2s.c:95:12: error: context imbalance in 'acp_i2s_set_tdm_slot' - different lock contexts for basic block

Fixes: cd60dec ("ASoC: amd: acp: Refactor TDM slots selction based on acp revision id")

On error path, function acp_i2s_set_tdm_slot returns without releasing
the lock and this could result in potential deadlocks in the future.

Error reported by sparse:
sound/soc/amd/acp/acp-i2s.c:95:12: error: context imbalance in
'acp_i2s_set_tdm_slot' - different lock contexts for basic block

Fixes: cd60dec ("ASoC: amd: acp: Refactor TDM slots selction based on acp revision id")
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
@dbaluta
Copy link
Collaborator Author

dbaluta commented Jan 22, 2025

@thesofproject/amd please have a look. This is only compile tested

@dbaluta
Copy link
Collaborator Author

dbaluta commented Jan 22, 2025

@lgirdwood there is still one issue reported by static checkers.

https://github.com/thesofproject/linux/actions/runs/12911457389/job/36003910540?pr=5304

sound/soc/sof/ipc4-topology.c: In function ‘sof_ipc4_prepare_copier_module’:
sound/soc/sof/ipc4-topology.c:1810:34: error: use of uninitialized value ‘((int *)<unknown>)[2]’ [CWE-457] [-Werror=analyzer-use-of-uninitialized-value]
 1810 |         struct snd_pcm_hw_params ref_params;
      |                                  ^~~~~~~~~~
  ‘sof_ipc4_prepare_copier_module’: events 1-4
    |
    | 1810 |         struct snd_pcm_hw_params ref_params;
    |      |                                  ^~~~~~~~~~
    |      |                                  |
    |      |                                  (1) region created on stack here
    |      |                                  (2) following ‘true’ branch...
    |      |                                  (3) ...to here
    |      |                                  (4) use of uninitialized value ‘((int *)<unknown>)[2]’ here
    |
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:194: sound/soc/sof/ipc4-topology.o] Error 1

but I wasn't able to understand where is the problem. Could be a false positive?

@ranj063
Copy link
Collaborator

ranj063 commented Jan 22, 2025

but I wasn't able to understand where is the problem. Could be a false positive?

@dbaluta looks like a false positive but perhaps will can init the ref_params to {} to silence the static analyzer?

@bardliao bardliao merged commit 965963c into thesofproject:topic/sof-dev Jan 23, 2025
8 of 9 checks passed
Copy link

@vijendarmukunda vijendarmukunda left a comment

Choose a reason for hiding this comment

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

LGTM

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.

5 participants