Commit 7411ddb9 authored by vulab's avatar vulab Committed by Wentao Guan
Browse files

ALSA: hda: Add error check for snd_ctl_rename_id() in snd_hda_create_dig_out_ctls()

stable inclusion
from stable-v6.6.80
commit edcb866a93bb9d64183aaae2d4cb0ad5c5c64913
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBXANC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=edcb866a93bb9d64183aaae2d4cb0ad5c5c64913



--------------------------------

commit 822b7ec657e99b44b874e052d8540d8b54fe8569 upstream.

Check the return value of snd_ctl_rename_id() in
snd_hda_create_dig_out_ctls(). Ensure that failures
are properly handled.

[ Note: the error cannot happen practically because the only error
  condition in snd_ctl_rename_id() is the missing ID, but this is a
  rename, hence it must be present.  But for the code consistency,
  it's safer to have always the proper return check -- tiwai ]

Fixes: 5c219a34 ("ALSA: hda: Fix kctl->id initialization")
Cc: stable@vger.kernel.org # 6.4+
Signed-off-by: default avatarWentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20250213074543.1620-1-vulab@iscas.ac.cn


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit edcb866a93bb9d64183aaae2d4cb0ad5c5c64913)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent 2933f04c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2463,7 +2463,9 @@ int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
				break;
			id = kctl->id;
			id.index = spdif_index;
			snd_ctl_rename_id(codec->card, &kctl->id, &id);
			err = snd_ctl_rename_id(codec->card, &kctl->id, &id);
			if (err < 0)
				return err;
		}
		bus->primary_dig_out_type = HDA_PCM_TYPE_HDMI;
	}