ALSA: hda: Add error check for snd_ctl_rename_id() in snd_hda_create_dig_out_ctls()
authorWentao Liang <vulab@iscas.ac.cn>
Thu, 13 Feb 2025 07:45:43 +0000 (15:45 +0800)
committerTakashi Iwai <tiwai@suse.de>
Fri, 14 Feb 2025 07:45:09 +0000 (08:45 +0100)
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: 5c219a340850 ("ALSA: hda: Fix kctl->id initialization")
Cc: stable@vger.kernel.org # 6.4+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20250213074543.1620-1-vulab@iscas.ac.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c

index 14763c0f31ad9ff2c1eafa646bc7d815254dd573..46a2204049993d9a6389c9701709d4ba392f2458 100644 (file)
@@ -2470,7 +2470,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;
        }