Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5513b0c5 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela
Browse files

[ALSA] hda-codec - Add zero checks in input-mux helper functions



Added zero checks in input-mux helper functions to avoid Oops.
Some devices may have no input pins while the driver registers
control elements calling these functions.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 2469049e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2341,6 +2341,8 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux,
	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
	uinfo->count = 1;
	uinfo->value.enumerated.items = imux->num_items;
	if (!imux->num_items)
		return 0;
	index = uinfo->value.enumerated.item;
	if (index >= imux->num_items)
		index = imux->num_items - 1;
@@ -2356,6 +2358,8 @@ int snd_hda_input_mux_put(struct hda_codec *codec,
{
	unsigned int idx;

	if (!imux->num_items)
		return 0;
	idx = ucontrol->value.enumerated.item[0];
	if (idx >= imux->num_items)
		idx = imux->num_items - 1;