ASoC: SOF: sof-client: Client drivers must not access sdev in any way#5449
Merged
ujfalusi merged 2 commits intothesofproject:topic/sof-devfrom Jun 13, 2025
Merged
Conversation
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>
bardliao
approved these changes
Jun 10, 2025
lyakh
reviewed
Jun 10, 2025
| { | ||
| return cdev->sdev; | ||
| } | ||
| EXPORT_SYMBOL_NS_GPL(sof_client_dev_to_sof_dev, "SND_SOC_SOF_CLIENT"); |
Collaborator
There was a problem hiding this comment.
@ujfalusi I thought that client devices shouldn't deal with struct snd_sof_dev at all, then why is this function exported?
Collaborator
Author
There was a problem hiding this comment.
@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.
ranj063
approved these changes
Jun 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The series will re-arrange the client device struct to 'hide' the sdev (and the list) from client drivers to prevent abuse.