Skip to content

Commit 28b329f

Browse files
rfvirgiltiwai
authored andcommitted
ALSA: hda: hda_component: Fix mutex crash if nothing ever binds
Move the initialization of parent->mutex into hda_component_manager_init() so that it is always valid. In hda_component_manager_bind() do not clear the parent information. Only zero-fill the per-component data ready for it to be filled in by the components as they bind. Previously parent->mutex was being initialized only in hda_component_manager_bind(). This meant that it was only initialized if all components appeared and there was a bind callback. If there wasn't a bind the mutex object was not valid when the Realtek driver called any of the other functions. Signed-off-by: Richard Fitzgerald <[email protected]> Fixes: 047b9cb ("ALSA: hda: hda_component: Protect shared data with a mutex") Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 2dc43c5 commit 28b329f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sound/pci/hda/hda_component.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ int hda_component_manager_bind(struct hda_codec *cdc,
141141
int ret;
142142

143143
/* Init shared and component specific data */
144-
memset(parent, 0, sizeof(*parent));
145-
mutex_init(&parent->mutex);
144+
memset(parent->comps, 0, sizeof(parent->comps));
146145
parent->codec = cdc;
147146

148147
mutex_lock(&parent->mutex);
@@ -164,6 +163,8 @@ int hda_component_manager_init(struct hda_codec *cdc,
164163
struct hda_scodec_match *sm;
165164
int ret, i;
166165

166+
mutex_init(&parent->mutex);
167+
167168
for (i = 0; i < count; i++) {
168169
sm = devm_kmalloc(dev, sizeof(*sm), GFP_KERNEL);
169170
if (!sm)

0 commit comments

Comments
 (0)