summaryrefslogtreecommitdiff
path: root/sound/pci/hda/hda_component.h
diff options
context:
space:
mode:
authorSimon Trimmer <simont@opensource.cirrus.com>2024-06-17 16:41:05 +0100
committerTakashi Iwai <tiwai@suse.de>2024-06-18 11:58:45 +0200
commit047b9cbbaa8ee3f1d71ff07d181ea6397be97ffe (patch)
tree17389be88655db90d359b42099b5760acd328c7d /sound/pci/hda/hda_component.h
parent3b2a8582876d0b1ff1d8df9ff3cca03a70268fe2 (diff)
ALSA: hda: hda_component: Protect shared data with a mutex
The hda_component contains information shared from the amp drivers to the codec that can be altered (for example as the driver unloads). Guard the update and use of these to prevent use of stale data. Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/20240617154105.108635-5-simont@opensource.cirrus.com
Diffstat (limited to 'sound/pci/hda/hda_component.h')
-rw-r--r--sound/pci/hda/hda_component.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_component.h b/sound/pci/hda/hda_component.h
index dd4dabeae9ee..9f786608144c 100644
--- a/sound/pci/hda/hda_component.h
+++ b/sound/pci/hda/hda_component.h
@@ -11,6 +11,7 @@
#include <linux/acpi.h>
#include <linux/component.h>
+#include <linux/mutex.h>
#include <sound/hda_codec.h>
#define HDA_MAX_COMPONENTS 4
@@ -28,6 +29,7 @@ struct hda_component {
};
struct hda_component_parent {
+ struct mutex mutex;
struct hda_codec *codec;
struct hda_component comps[HDA_MAX_COMPONENTS];
};
@@ -93,7 +95,9 @@ static inline struct hda_component *hda_component_from_index(struct hda_componen
static inline void hda_component_manager_unbind(struct hda_codec *cdc,
struct hda_component_parent *parent)
{
+ mutex_lock(&parent->mutex);
component_unbind_all(hda_codec_dev(cdc), parent);
+ mutex_unlock(&parent->mutex);
}
#endif /* ifndef __HDA_COMPONENT_H__ */