Skip to content

ASoC: SOF: sof-client: Client drivers must not access sdev in any way#5449

Merged
ujfalusi merged 2 commits intothesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/sof-clients-no-sdev-01
Jun 13, 2025
Merged

ASoC: SOF: sof-client: Client drivers must not access sdev in any way#5449
ujfalusi merged 2 commits intothesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/sof-clients-no-sdev-01

Conversation

@ujfalusi
Copy link
Collaborator

@ujfalusi ujfalusi commented Jun 9, 2025

The series will re-arrange the client device struct to 'hide' the sdev (and the list) from client drivers to prevent abuse.

ujfalusi added 2 commits June 9, 2025 17:09
Remove the sof_client_dev_to_sof_dev() from the header file and add it as
a function in sof-client.c to avoid it's use by client drivers.

At the same time mark the sdev and list of sof_client_dev as restricted
fro core use only.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Introduce a new internal structure for wrapping the sof_client_dev and
move members away from the client visible struct that they must not
access, let alone see (sdev and the list).

The changes are mechanical in nature and contained within sof-client core
code, no functional change or change in behavior is introduced.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Copy link

@jsarha jsarha left a comment

Choose a reason for hiding this comment

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

LGTM

{
return cdev->sdev;
}
EXPORT_SYMBOL_NS_GPL(sof_client_dev_to_sof_dev, "SND_SOC_SOF_CLIENT");
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ujfalusi I thought that client devices shouldn't deal with struct snd_sof_dev at all, then why is this function exported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh, right, the other core used functions also have been exported with this symbol, the other option is to not use namespace for these at all. The definition is in sof-priv.h, which is also forbidden to be included by client drivers.

We can make this over complicated, but I think during review this can be spotted and enforced.

@ujfalusi ujfalusi merged commit 075b7dd into thesofproject:topic/sof-dev Jun 13, 2025
8 of 16 checks passed
@ujfalusi ujfalusi deleted the peter/sof/pr/sof-clients-no-sdev-01 branch October 2, 2025 06:27
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