mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 00:20:52 -05:00
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 <rf@opensource.cirrus.com>
Fixes: 047b9cbbaa
("ALSA: hda: hda_component: Protect shared data with a mutex")
Link: https://patch.msgid.link/20240826094940.45563-1-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2dc43c5e21
commit
28b329f431
1 changed files with 3 additions and 2 deletions
|
@ -141,8 +141,7 @@ int hda_component_manager_bind(struct hda_codec *cdc,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Init shared and component specific data */
|
/* Init shared and component specific data */
|
||||||
memset(parent, 0, sizeof(*parent));
|
memset(parent->comps, 0, sizeof(parent->comps));
|
||||||
mutex_init(&parent->mutex);
|
|
||||||
parent->codec = cdc;
|
parent->codec = cdc;
|
||||||
|
|
||||||
mutex_lock(&parent->mutex);
|
mutex_lock(&parent->mutex);
|
||||||
|
@ -164,6 +163,8 @@ int hda_component_manager_init(struct hda_codec *cdc,
|
||||||
struct hda_scodec_match *sm;
|
struct hda_scodec_match *sm;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
|
mutex_init(&parent->mutex);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
sm = devm_kmalloc(dev, sizeof(*sm), GFP_KERNEL);
|
sm = devm_kmalloc(dev, sizeof(*sm), GFP_KERNEL);
|
||||||
if (!sm)
|
if (!sm)
|
||||||
|
|
Loading…
Reference in a new issue