Skip to content

Commit 9a4a6f0

Browse files
committed
Merge tag 'sound-5.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "The important fixes at this time are a couple fixes in ALSA core: a fix for PCM is about the OOB access in PCM OSS plugins that has been for long time, but hasn't hit so often until now just because we allocated a large buffer via vmalloc(), and surfaced more often after switching to kvmalloc(). Another fix is for a long-standing PCM problem wrt racy PM resume. Others are trivial nospec coverage and usual HD-audio quirks" * tag 'sound-5.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: hda/realtek - Fix speakers on Acer Predator Helios 500 Ryzen laptops ALSA: pcm: Don't suspend stream in unrecoverable PCM state ALSA: hda/ca0132 - Simplify alt firmware loading code ALSA: pcm: Fix possible OOB access in PCM oss plugins ALSA: hda/realtek: Enable headset MIC of ASUS X430UN and X512DK with ALC256 ALSA: hda/realtek: Enable headset mic of ASUS P5440FF with ALC256 ALSA: hda/realtek: Enable ASUS X441MB and X705FD headset MIC with ALC256 ALSA: hda/realtek - Add support for Acer Aspire E5-523G/ES1-432 headset mic ALSA: hda/realtek: Enable headset MIC of Acer Aspire Z24-890 with ALC286 ALSA: seq: oss: Fix Spectre v1 vulnerability ALSA: rawmidi: Fix potential Spectre v1 vulnerability
2 parents 0e40da3 + e2a829b commit 9a4a6f0

File tree

6 files changed

+77
-39
lines changed

6 files changed

+77
-39
lines changed

sound/core/oss/pcm_oss.c

+22-21
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,28 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
940940
oss_frame_size = snd_pcm_format_physical_width(params_format(params)) *
941941
params_channels(params) / 8;
942942

943+
err = snd_pcm_oss_period_size(substream, params, sparams);
944+
if (err < 0)
945+
goto failure;
946+
947+
n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
948+
err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
949+
if (err < 0)
950+
goto failure;
951+
952+
err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
953+
runtime->oss.periods, NULL);
954+
if (err < 0)
955+
goto failure;
956+
957+
snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
958+
959+
err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams);
960+
if (err < 0) {
961+
pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err);
962+
goto failure;
963+
}
964+
943965
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
944966
snd_pcm_oss_plugin_clear(substream);
945967
if (!direct) {
@@ -974,27 +996,6 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
974996
}
975997
#endif
976998

977-
err = snd_pcm_oss_period_size(substream, params, sparams);
978-
if (err < 0)
979-
goto failure;
980-
981-
n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
982-
err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
983-
if (err < 0)
984-
goto failure;
985-
986-
err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
987-
runtime->oss.periods, NULL);
988-
if (err < 0)
989-
goto failure;
990-
991-
snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
992-
993-
if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams)) < 0) {
994-
pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err);
995-
goto failure;
996-
}
997-
998999
if (runtime->oss.trigger) {
9991000
sw_params->start_threshold = 1;
10001001
} else {

sound/core/pcm_native.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -1445,8 +1445,15 @@ static int snd_pcm_pause(struct snd_pcm_substream *substream, int push)
14451445
static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state)
14461446
{
14471447
struct snd_pcm_runtime *runtime = substream->runtime;
1448-
if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
1448+
switch (runtime->status->state) {
1449+
case SNDRV_PCM_STATE_SUSPENDED:
14491450
return -EBUSY;
1451+
/* unresumable PCM state; return -EBUSY for skipping suspend */
1452+
case SNDRV_PCM_STATE_OPEN:
1453+
case SNDRV_PCM_STATE_SETUP:
1454+
case SNDRV_PCM_STATE_DISCONNECTED:
1455+
return -EBUSY;
1456+
}
14501457
runtime->trigger_master = substream;
14511458
return 0;
14521459
}

sound/core/rawmidi.c

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/module.h>
3131
#include <linux/delay.h>
3232
#include <linux/mm.h>
33+
#include <linux/nospec.h>
3334
#include <sound/rawmidi.h>
3435
#include <sound/info.h>
3536
#include <sound/control.h>
@@ -601,6 +602,7 @@ static int __snd_rawmidi_info_select(struct snd_card *card,
601602
return -ENXIO;
602603
if (info->stream < 0 || info->stream > 1)
603604
return -EINVAL;
605+
info->stream = array_index_nospec(info->stream, 2);
604606
pstr = &rmidi->streams[info->stream];
605607
if (pstr->substream_count == 0)
606608
return -ENOENT;

sound/core/seq/oss/seq_oss_synth.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,14 @@ int
617617
snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_info *inf)
618618
{
619619
struct seq_oss_synth *rec;
620+
struct seq_oss_synthinfo *info = get_synthinfo_nospec(dp, dev);
620621

621-
if (dev < 0 || dev >= dp->max_synthdev)
622+
if (!info)
622623
return -ENXIO;
623624

624-
if (dp->synths[dev].is_midi) {
625+
if (info->is_midi) {
625626
struct midi_info minf;
626-
snd_seq_oss_midi_make_info(dp, dp->synths[dev].midi_mapped, &minf);
627+
snd_seq_oss_midi_make_info(dp, info->midi_mapped, &minf);
627628
inf->synth_type = SYNTH_TYPE_MIDI;
628629
inf->synth_subtype = 0;
629630
inf->nr_voices = 16;

sound/pci/hda/patch_ca0132.c

+6-14
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ struct ca0132_spec {
10051005
unsigned int scp_resp_header;
10061006
unsigned int scp_resp_data[4];
10071007
unsigned int scp_resp_count;
1008-
bool alt_firmware_present;
10091008
bool startup_check_entered;
10101009
bool dsp_reload;
10111010

@@ -7518,7 +7517,7 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
75187517
bool dsp_loaded = false;
75197518
struct ca0132_spec *spec = codec->spec;
75207519
const struct dsp_image_seg *dsp_os_image;
7521-
const struct firmware *fw_entry;
7520+
const struct firmware *fw_entry = NULL;
75227521
/*
75237522
* Alternate firmwares for different variants. The Recon3Di apparently
75247523
* can use the default firmware, but I'll leave the option in case
@@ -7529,33 +7528,26 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
75297528
case QUIRK_R3D:
75307529
case QUIRK_AE5:
75317530
if (request_firmware(&fw_entry, DESKTOP_EFX_FILE,
7532-
codec->card->dev) != 0) {
7531+
codec->card->dev) != 0)
75337532
codec_dbg(codec, "Desktop firmware not found.");
7534-
spec->alt_firmware_present = false;
7535-
} else {
7533+
else
75367534
codec_dbg(codec, "Desktop firmware selected.");
7537-
spec->alt_firmware_present = true;
7538-
}
75397535
break;
75407536
case QUIRK_R3DI:
75417537
if (request_firmware(&fw_entry, R3DI_EFX_FILE,
7542-
codec->card->dev) != 0) {
7538+
codec->card->dev) != 0)
75437539
codec_dbg(codec, "Recon3Di alt firmware not detected.");
7544-
spec->alt_firmware_present = false;
7545-
} else {
7540+
else
75467541
codec_dbg(codec, "Recon3Di firmware selected.");
7547-
spec->alt_firmware_present = true;
7548-
}
75497542
break;
75507543
default:
7551-
spec->alt_firmware_present = false;
75527544
break;
75537545
}
75547546
/*
75557547
* Use default ctefx.bin if no alt firmware is detected, or if none
75567548
* exists for your particular codec.
75577549
*/
7558-
if (!spec->alt_firmware_present) {
7550+
if (!fw_entry) {
75597551
codec_dbg(codec, "Default firmware selected.");
75607552
if (request_firmware(&fw_entry, EFX_FILE,
75617553
codec->card->dev) != 0)

sound/pci/hda/patch_realtek.c

+35
Original file line numberDiff line numberDiff line change
@@ -5688,6 +5688,8 @@ enum {
56885688
ALC225_FIXUP_WYSE_AUTO_MUTE,
56895689
ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
56905690
ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
5691+
ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
5692+
ALC299_FIXUP_PREDATOR_SPK,
56915693
};
56925694

56935695
static const struct hda_fixup alc269_fixups[] = {
@@ -6696,6 +6698,22 @@ static const struct hda_fixup alc269_fixups[] = {
66966698
.chained = true,
66976699
.chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
66986700
},
6701+
[ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6702+
.type = HDA_FIXUP_PINS,
6703+
.v.pins = (const struct hda_pintbl[]) {
6704+
{ 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6705+
{ }
6706+
},
6707+
.chained = true,
6708+
.chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6709+
},
6710+
[ALC299_FIXUP_PREDATOR_SPK] = {
6711+
.type = HDA_FIXUP_PINS,
6712+
.v.pins = (const struct hda_pintbl[]) {
6713+
{ 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
6714+
{ }
6715+
}
6716+
},
66996717
};
67006718

67016719
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -6712,9 +6730,13 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
67126730
SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
67136731
SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
67146732
SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
6733+
SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
6734+
SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
6735+
SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
67156736
SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
67166737
SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
67176738
SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
6739+
SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
67186740
SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
67196741
SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
67206742
SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
@@ -7111,6 +7133,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
71117133
{.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
71127134
{.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
71137135
{.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-sense-combo"},
7136+
{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
71147137
{}
71157138
};
71167139
#define ALC225_STANDARD_PINS \
@@ -7331,6 +7354,18 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
73317354
{0x14, 0x90170110},
73327355
{0x1b, 0x90a70130},
73337356
{0x21, 0x03211020}),
7357+
SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7358+
{0x12, 0x90a60130},
7359+
{0x14, 0x90170110},
7360+
{0x21, 0x03211020}),
7361+
SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7362+
{0x12, 0x90a60130},
7363+
{0x14, 0x90170110},
7364+
{0x21, 0x04211020}),
7365+
SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7366+
{0x1a, 0x90a70130},
7367+
{0x1b, 0x90170110},
7368+
{0x21, 0x03211020}),
73347369
SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
73357370
{0x12, 0xb7a60130},
73367371
{0x13, 0xb8a61140},

0 commit comments

Comments
 (0)