we should not access any of its memory when we don't ensure possession of a read/write lock. Otherwise we risk a use after free access, which allows local users to cause a denial of service and obtain sensitive information from kernel memory.
Signed-off-by: Ma Ke make_ruc2021@163.com --- sound/core/control.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/core/control.c b/sound/core/control.c index 59c8658966d4..98782cc68ee1 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -590,7 +590,8 @@ static int __snd_ctl_remove(struct snd_card *card, remove_hash_entries(card, kcontrol);
card->controls_count -= kcontrol->count; - for (idx = 0; idx < kcontrol->count; idx++) + count = kcontrol->count; + for (idx = 0; idx < count; idx++) snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx); snd_ctl_free_one(kcontrol); return 0;