ALSA: es1938: check snd_ctl_new1() return value
Subsystems (3)
PATCH v2 1/6 ALSA: es1938: check snd_ctl_new1() return value
In reply to a message not in the archiveFrom: Zhao Dongdong <[email protected]>
snd_ctl_new1() can return NULL when memory allocation fails. snd_es1938_mixer() does not check the return value before dereferencing the pointer, which can lead to a NULL pointer dereference.
Add a NULL check after snd_ctl_new1() and return -ENOMEM if it fails.
--- sound/pci/es1938.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/es1938.c +2 -0
@@ -1655,6 +1655,8 @@ static int snd_es1938_mixer(struct es1938 *chip)for (idx =0 ; idx <ARRAY_SIZE (snd_es1938_controls); idx++) {struct snd_kcontrol *kctl; kctl =snd_ctl_new1 (&snd_es1938_controls[idx], chip); +if (!kctl) +return -ENOMEM ;switch (idx) {case 0 : chip->master_volume = kctl;
Signature · 1 line
2.25.1
PATCH v2 2/6 ALSA: gus: check snd_ctl_new1() return value
In reply to a message not in the archiveFrom: Zhao Dongdong <[email protected]>
snd_ctl_new1() can return NULL when memory allocation fails. snd_gf1_pcm_volume_control() does not check the return value before dereferencing kctl->id.index, which can lead to a NULL pointer dereference.
Add a NULL check after snd_ctl_new1() and return -ENOMEM if it fails.
--- sound/isa/gus/gus_pcm.c | 2 ++ 1 file changed, 2 insertions(+)
sound/isa/gus/gus_pcm.c +2 -0
@@ -851,6 +851,8 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) kctl =snd_ctl_new1 (&snd_gf1_pcm_volume_control1, gus); else kctl =snd_ctl_new1 (&snd_gf1_pcm_volume_control, gus); +if (!kctl) +return -ENOMEM ; kctl->id.index = control_index; err =snd_ctl_add (card, kctl);if (err <0 )
Signature · 1 line
2.25.1
PATCH v2 4/6 ALSA: ymfpci: check snd_ctl_new1() return value
In reply to a message not in the archiveFrom: Zhao Dongdong <[email protected]>
snd_ctl_new1() can return NULL when memory allocation fails. snd_ymfpci_create_spdif_controls() does not check the return value before dereferencing kctl->id.device, which can lead to a NULL pointer dereference.
Add NULL checks after snd_ctl_new1() calls and return -ENOMEM if any fails.
--- sound/pci/ymfpci/ymfpci_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/pci/ymfpci/ymfpci_main.c +6 -0
@@ -1781,16 +1781,22 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch)if (snd_BUG_ON (!chip->pcm_spdif))return -ENXIO ; kctl =snd_ctl_new1 (&snd_ymfpci_spdif_default, chip); +if (!kctl) +return -ENOMEM ; kctl->id.device = chip->pcm_spdif->device; err =snd_ctl_add (chip->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_ymfpci_spdif_mask, chip); +if (!kctl) +return -ENOMEM ; kctl->id.device = chip->pcm_spdif->device; err =snd_ctl_add (chip->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_ymfpci_spdif_stream, chip); +if (!kctl) +return -ENOMEM ; kctl->id.device = chip->pcm_spdif->device; err =snd_ctl_add (chip->card, kctl);if (err <0 )
Signature · 1 line
2.25.1
PATCH v2 6/6 ALSA: aoa: check snd_ctl_new1() return value
In reply to a message not in the archiveFrom: Zhao Dongdong <[email protected]>
snd_ctl_new1() can return NULL when memory allocation fails. In layout.c, the function does not check the return value before dereferencing ctl->id.name or passing to aoa_snd_ctl_add(), which can lead to a NULL pointer dereference.
Add NULL checks after snd_ctl_new1() calls and return early if any fails.
--- sound/aoa/fabrics/layout.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/aoa/fabrics/layout.c +6 -0
@@ -948,6 +948,8 @@ static void layout_attached_codec(struct aoa_codec *codec)if (lineout ==1 ) ldev->gpio.methods->set_lineout (codec->gpio,1 ); ctl =snd_ctl_new1 (&lineout_ctl, codec->gpio); +if (!ctl) +return ;if (cc->connected &CC_LINEOUT_LABELLED_HEADPHONE )strscpy (ctl->id.name,"Headphone Switch" ); ldev->lineout_ctrl = ctl;
@@ -961,12 +963,16 @@ static void layout_attached_codec(struct aoa_codec *codec)if (ldev->have_lineout_detect) { ctl =snd_ctl_new1 (&lineout_detect_choice, ldev); +if (!ctl) +return ;if (cc->connected &CC_LINEOUT_LABELLED_HEADPHONE )strscpy (ctl->id.name,"Headphone Detect Autoswitch" );aoa_snd_ctl_add (ctl); ctl =snd_ctl_new1 (&lineout_detected, ldev); +if (!ctl) +return ;if (cc->connected &CC_LINEOUT_LABELLED_HEADPHONE )strscpy (ctl->id.name,"Headphone Detected" );
Signature · 1 line
2.25.1
PATCH v2 3/6 ALSA: ice1712: check snd_ctl_new1() return value
In reply to a message not in the archiveFrom: Zhao Dongdong <[email protected]>
snd_ctl_new1() can return NULL when memory allocation fails. The ice1712 driver calls snd_ctl_new1() without checking the return value before dereferencing the pointer in multiple places (ice1712.c, ice1724.c, aureon.c), which can lead to NULL pointer dereferences.
Add NULL checks after snd_ctl_new1() calls and return -ENOMEM if any fails.
--- sound/pci/ice1712/aureon.c | 2 ++ sound/pci/ice1712/ice1712.c | 8 ++++++++ sound/pci/ice1712/ice1724.c | 6 ++++++ 3 files changed, 16 insertions(+)
sound/pci/ice1712/aureon.c +2 -0
@@ -1891,6 +1891,8 @@ static int aureon_add_controls(struct snd_ice1712 *ice)for (i =0 ; i <ARRAY_SIZE (cs8415_controls); i++) {struct snd_kcontrol *kctl; kctl =snd_ctl_new1 (&cs8415_controls[i], ice); +if (!kctl) +return -ENOMEM ;if (i >1 ) kctl->id.device = ice->pcm->device; err =snd_ctl_add (ice->card, kctl);
sound/pci/ice1712/ice1712.c +8 -0
@@ -2346,21 +2346,29 @@ int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)if (snd_BUG_ON (!ice->pcm_pro))return -EIO ; kctl =snd_ctl_new1 (&snd_ice1712_spdif_default, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm_pro->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_ice1712_spdif_maskc, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm_pro->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_ice1712_spdif_maskp, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm_pro->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_ice1712_spdif_stream, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm_pro->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )
sound/pci/ice1712/ice1724.c +6 -0
@@ -2379,16 +2379,22 @@ static int snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice)return err; kctl =snd_ctl_new1 (&snd_vt1724_spdif_default, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_vt1724_spdif_maskc, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_vt1724_spdif_maskp, ice); +if (!kctl) +return -ENOMEM ; kctl->id.device = ice->pcm->device; err =snd_ctl_add (ice->card, kctl);if (err <0 )
Signature · 1 line
2.25.1
PATCH v2 5/6 ALSA: cmipci: check snd_ctl_new1() return value
In reply to a message not in the archiveFrom: Zhao Dongdong <[email protected]>
snd_ctl_new1() can return NULL when memory allocation fails. snd_cmipci_spdif_controls() does not check the return value before dereferencing kctl->id.device, which can lead to a NULL pointer dereference.
Add NULL checks after snd_ctl_new1() calls and return -ENOMEM if any fails.
--- sound/pci/cmipci.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/pci/cmipci.c +6 -0
@@ -2637,16 +2637,22 @@ static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) }if (cm->can_ac3_hw) { kctl =snd_ctl_new1 (&snd_cmipci_spdif_default, cm); +if (!kctl) +return -ENOMEM ; kctl->id.device = pcm_spdif_device; err =snd_ctl_add (card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_cmipci_spdif_mask, cm); +if (!kctl) +return -ENOMEM ; kctl->id.device = pcm_spdif_device; err =snd_ctl_add (card, kctl);if (err <0 )return err; kctl =snd_ctl_new1 (&snd_cmipci_spdif_stream, cm); +if (!kctl) +return -ENOMEM ; kctl->id.device = pcm_spdif_device; err =snd_ctl_add (card, kctl);if (err <0 )
Signature · 1 line
2.25.1