Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: control: Add lockdep warning to internal functions

To assure the proper locking, add the lockdep check to
__snd_ctl_remove(), __snd_ctl_add_replace() and other internal
functions to handle user controls.

Link: https://lore.kernel.org/r/20230718141304.1032-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+10
+10
sound/core/control.c
··· 469 469 struct snd_kcontrol *old; 470 470 int err; 471 471 472 + lockdep_assert_held_write(&card->controls_rwsem); 473 + 472 474 id = kcontrol->id; 473 475 if (id.index > UINT_MAX - kcontrol->count) 474 476 return -EINVAL; ··· 579 577 bool remove_hash) 580 578 { 581 579 unsigned int idx; 580 + 581 + lockdep_assert_held_write(&card->controls_rwsem); 582 582 583 583 if (snd_BUG_ON(!card || !kcontrol)) 584 584 return -EINVAL; ··· 1528 1524 int i; 1529 1525 int change; 1530 1526 1527 + lockdep_assert_held_write(&ue->card->controls_rwsem); 1528 + 1531 1529 if (size > 1024 * 128) /* sane value */ 1532 1530 return -EINVAL; 1533 1531 ··· 1605 1599 size_t buf_len, name_len; 1606 1600 unsigned int i; 1607 1601 const uintptr_t user_ptrval = ue->info.value.enumerated.names_ptr; 1602 + 1603 + lockdep_assert_held_write(&ue->card->controls_rwsem); 1608 1604 1609 1605 buf_len = ue->info.value.enumerated.names_length; 1610 1606 if (buf_len > 64 * 1024) ··· 1911 1903 struct snd_kcontrol *kctl; 1912 1904 struct snd_ctl_elem_id id; 1913 1905 struct snd_kcontrol_volatile *vd; 1906 + 1907 + lockdep_assert_held(&file->card->controls_rwsem); 1914 1908 1915 1909 if (copy_from_user(&header, buf, sizeof(header))) 1916 1910 return -EFAULT;