Commit f186fd2f authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull sound fixes from Takashi Iwai:
 "A collection of small fixes:

   - fixes for regressions by the recent ALSA control hash usages

   - fixes for UAF with del_timer() at removals in a few drivers

   - char signedness fixes

   - a few memory leak fixes in error paths

   - device-specific fixes / quirks for Intel SOF, AMD, HD-audio,
     USB-audio, and various ASoC codecs"

* tag 'sound-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (50 commits)
  ALSA: aoa: Fix I2S device accounting
  ALSA: Use del_timer_sync() before freeing timer
  ALSA: aoa: i2sbus: fix possible memory leak in i2sbus_add_dev()
  ALSA: rme9652: use explicitly signed char
  ALSA: au88x0: use explicitly signed char
  ALSA: hda/realtek: Add another HP ZBook G9 model quirks
  ALSA: usb-audio: Add quirks for M-Audio Fast Track C400/600
  ASoC: SOF: Intel: hda-codec: fix possible memory leak in hda_codec_device_init()
  ASoC: amd: yc: Add Lenovo Thinkbook 14+ 2022 21D0 to quirks table
  ASoC: Intel: Skylake: fix possible memory leak in skl_codec_device_init()
  ALSA: ac97: Use snd_ctl_rename() to rename a control
  ALSA: ca0106: Use snd_ctl_rename() to rename a control
  ALSA: emu10k1: Use snd_ctl_rename() to rename a control
  ALSA: hda/realtek: Use snd_ctl_rename() to rename a control
  ALSA: usb-audio: Use snd_ctl_rename() to rename a control
  ALSA: control: add snd_ctl_rename()
  ALSA: ac97: fix possible memory leak in snd_ac97_dev_register()
  ASoC: SOF: Intel: pci-tgl: fix ADL-N descriptor
  ASoC: qcom: lpass-cpu: Mark HDMI TX parity register as volatile
  ASoC: amd: yc: Adding Lenovo ThinkBook 14 Gen 4+ ARA and Lenovo ThinkBook 16 Gen 4+ ARA to the Quirks List
  ...
parents e3493d68 f1fae475
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace);
int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
void snd_ctl_rename(struct snd_card *card, struct snd_kcontrol *kctl, const char *name);
int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, int active);
struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
+1 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data,
				      struct snd_pcm_hw_params *params);
void asoc_simple_parse_convert(struct device_node *np, char *prefix,
			       struct asoc_simple_data *data);
bool asoc_simple_is_convert_required(const struct asoc_simple_data *data);

int asoc_simple_parse_routing(struct snd_soc_card *card,
				      char *prefix);
+6 −1
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ static int i2sbus_get_and_fixup_rsrc(struct device_node *np, int index,
	return rc;
}

/* Returns 1 if added, 0 for otherwise; don't return a negative value! */
/* FIXME: look at device node refcounting */
static int i2sbus_add_dev(struct macio_dev *macio,
			  struct i2sbus_control *control,
@@ -213,7 +214,7 @@ static int i2sbus_add_dev(struct macio_dev *macio,
	 * either as the second one in that case is just a modem. */
	if (!ok) {
		kfree(dev);
		return -ENODEV;
		return 0;
	}

	mutex_init(&dev->lock);
@@ -302,6 +303,10 @@ static int i2sbus_add_dev(struct macio_dev *macio,

	if (soundbus_add_one(&dev->sound)) {
		printk(KERN_DEBUG "i2sbus: device registration error!\n");
		if (dev->sound.ofdev.dev.kobj.state_initialized) {
			soundbus_dev_put(&dev->sound);
			return 0;
		}
		goto err;
	}

+23 −0
Original line number Diff line number Diff line
@@ -753,6 +753,29 @@ int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id,
}
EXPORT_SYMBOL(snd_ctl_rename_id);

/**
 * snd_ctl_rename - rename the control on the card
 * @card: the card instance
 * @kctl: the control to rename
 * @name: the new name
 *
 * Renames the specified control on the card to the new name.
 *
 * Make sure to take the control write lock - down_write(&card->controls_rwsem).
 */
void snd_ctl_rename(struct snd_card *card, struct snd_kcontrol *kctl,
		    const char *name)
{
	remove_hash_entries(card, kctl);

	if (strscpy(kctl->id.name, name, sizeof(kctl->id.name)) < 0)
		pr_warn("ALSA: Renamed control new name '%s' truncated to '%s'\n",
			name, kctl->id.name);

	add_hash_entries(card, kctl);
}
EXPORT_SYMBOL(snd_ctl_rename);

#ifndef CONFIG_SND_CTL_FAST_LOOKUP
static struct snd_kcontrol *
snd_ctl_find_numid_slow(struct snd_card *card, unsigned int numid)
+25 −8
Original line number Diff line number Diff line
@@ -2009,6 +2009,7 @@ static int snd_ac97_dev_register(struct snd_device *device)
	err = device_register(&ac97->dev);
	if (err < 0) {
		ac97_err(ac97, "Can't register ac97 bus\n");
		put_device(&ac97->dev);
		ac97->dev.bus = NULL;
		return err;
	}
@@ -2655,10 +2656,17 @@ EXPORT_SYMBOL(snd_ac97_resume);
 */
static void set_ctl_name(char *dst, const char *src, const char *suffix)
{
	if (suffix)
		sprintf(dst, "%s %s", src, suffix);
	else
		strcpy(dst, src);
	const size_t msize = SNDRV_CTL_ELEM_ID_NAME_MAXLEN;

	if (suffix) {
		if (snprintf(dst, msize, "%s %s", src, suffix) >= msize)
			pr_warn("ALSA: AC97 control name '%s %s' truncated to '%s'\n",
				src, suffix, dst);
	} else {
		if (strscpy(dst, src, msize) < 0)
			pr_warn("ALSA: AC97 control name '%s' truncated to '%s'\n",
				src, dst);
	}
}

/* remove the control with the given name and optional suffix */
@@ -2686,8 +2694,11 @@ static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
			       const char *dst, const char *suffix)
{
	struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix);
	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];

	if (kctl) {
		set_ctl_name(kctl->id.name, dst, suffix);
		set_ctl_name(name, dst, suffix);
		snd_ctl_rename(ac97->bus->card, kctl, name);
		return 0;
	}
	return -ENOENT;
@@ -2706,11 +2717,17 @@ static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
			     const char *s2, const char *suffix)
{
	struct snd_kcontrol *kctl1, *kctl2;
	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];

	kctl1 = ctl_find(ac97, s1, suffix);
	kctl2 = ctl_find(ac97, s2, suffix);
	if (kctl1 && kctl2) {
		set_ctl_name(kctl1->id.name, s2, suffix);
		set_ctl_name(kctl2->id.name, s1, suffix);
		set_ctl_name(name, s2, suffix);
		snd_ctl_rename(ac97->bus->card, kctl1, name);

		set_ctl_name(name, s1, suffix);
		snd_ctl_rename(ac97->bus->card, kctl2, name);

		return 0;
	}
	return -ENOENT;
Loading