Skip to content

Commit 2708d17

Browse files
committed
Merge tag 'sound-4.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "A collection of small fixes: - a fix in ALSA timer core to avoid possible BUG() trigger - a fix in ALSA timer core 32bit compat layer - a few HD-audio quirks for ASUS and HP machines - AMD HD-audio HDMI controller quirks - fixes of USB-audio double-free at some error paths - a fix for memory leak in DICE driver at hotunplug" * tag 'sound-4.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: timer: Use mod_timer() for rearming the system timer ALSA: hda - fix front mic problem for a HP desktop ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call ALSA: hda: add AMD Polaris-10/11 AZ PCI IDs with proper driver caps ALSA: dice: fix memory leak when unplugging ALSA: hda - Apply fix for white noise on Asus N550JV, too ALSA: hda - Fix white noise on Asus N750JV headphone ALSA: hda - Asus N750JV external subwoofer fixup ALSA: timer: fix gparams ioctl compatibility for different architectures
2 parents 6ddf37d + 4a07083 commit 2708d17

File tree

7 files changed

+79
-22
lines changed

7 files changed

+79
-22
lines changed

sound/core/timer.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,8 @@ static int snd_timer_s_start(struct snd_timer * timer)
10191019
njiff += timer->sticks - priv->correction;
10201020
priv->correction = 0;
10211021
}
1022-
priv->last_expires = priv->tlist.expires = njiff;
1023-
add_timer(&priv->tlist);
1022+
priv->last_expires = njiff;
1023+
mod_timer(&priv->tlist, njiff);
10241024
return 0;
10251025
}
10261026

@@ -1502,17 +1502,13 @@ static int snd_timer_user_ginfo(struct file *file,
15021502
return err;
15031503
}
15041504

1505-
static int snd_timer_user_gparams(struct file *file,
1506-
struct snd_timer_gparams __user *_gparams)
1505+
static int timer_set_gparams(struct snd_timer_gparams *gparams)
15071506
{
1508-
struct snd_timer_gparams gparams;
15091507
struct snd_timer *t;
15101508
int err;
15111509

1512-
if (copy_from_user(&gparams, _gparams, sizeof(gparams)))
1513-
return -EFAULT;
15141510
mutex_lock(&register_mutex);
1515-
t = snd_timer_find(&gparams.tid);
1511+
t = snd_timer_find(&gparams->tid);
15161512
if (!t) {
15171513
err = -ENODEV;
15181514
goto _error;
@@ -1525,12 +1521,22 @@ static int snd_timer_user_gparams(struct file *file,
15251521
err = -ENOSYS;
15261522
goto _error;
15271523
}
1528-
err = t->hw.set_period(t, gparams.period_num, gparams.period_den);
1524+
err = t->hw.set_period(t, gparams->period_num, gparams->period_den);
15291525
_error:
15301526
mutex_unlock(&register_mutex);
15311527
return err;
15321528
}
15331529

1530+
static int snd_timer_user_gparams(struct file *file,
1531+
struct snd_timer_gparams __user *_gparams)
1532+
{
1533+
struct snd_timer_gparams gparams;
1534+
1535+
if (copy_from_user(&gparams, _gparams, sizeof(gparams)))
1536+
return -EFAULT;
1537+
return timer_set_gparams(&gparams);
1538+
}
1539+
15341540
static int snd_timer_user_gstatus(struct file *file,
15351541
struct snd_timer_gstatus __user *_gstatus)
15361542
{

sound/core/timer_compat.c

+29-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222

2323
#include <linux/compat.h>
2424

25+
/*
26+
* ILP32/LP64 has different size for 'long' type. Additionally, the size
27+
* of storage alignment differs depending on architectures. Here, '__packed'
28+
* qualifier is used so that the size of this structure is multiple of 4 and
29+
* it fits to any architectures with 32 bit storage alignment.
30+
*/
31+
struct snd_timer_gparams32 {
32+
struct snd_timer_id tid;
33+
u32 period_num;
34+
u32 period_den;
35+
unsigned char reserved[32];
36+
} __packed;
37+
2538
struct snd_timer_info32 {
2639
u32 flags;
2740
s32 card;
@@ -32,6 +45,19 @@ struct snd_timer_info32 {
3245
unsigned char reserved[64];
3346
};
3447

48+
static int snd_timer_user_gparams_compat(struct file *file,
49+
struct snd_timer_gparams32 __user *user)
50+
{
51+
struct snd_timer_gparams gparams;
52+
53+
if (copy_from_user(&gparams.tid, &user->tid, sizeof(gparams.tid)) ||
54+
get_user(gparams.period_num, &user->period_num) ||
55+
get_user(gparams.period_den, &user->period_den))
56+
return -EFAULT;
57+
58+
return timer_set_gparams(&gparams);
59+
}
60+
3561
static int snd_timer_user_info_compat(struct file *file,
3662
struct snd_timer_info32 __user *_info)
3763
{
@@ -99,6 +125,7 @@ static int snd_timer_user_status_compat(struct file *file,
99125
*/
100126

101127
enum {
128+
SNDRV_TIMER_IOCTL_GPARAMS32 = _IOW('T', 0x04, struct snd_timer_gparams32),
102129
SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32),
103130
SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32),
104131
#ifdef CONFIG_X86_X32
@@ -114,7 +141,6 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
114141
case SNDRV_TIMER_IOCTL_PVERSION:
115142
case SNDRV_TIMER_IOCTL_TREAD:
116143
case SNDRV_TIMER_IOCTL_GINFO:
117-
case SNDRV_TIMER_IOCTL_GPARAMS:
118144
case SNDRV_TIMER_IOCTL_GSTATUS:
119145
case SNDRV_TIMER_IOCTL_SELECT:
120146
case SNDRV_TIMER_IOCTL_PARAMS:
@@ -128,6 +154,8 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
128154
case SNDRV_TIMER_IOCTL_PAUSE_OLD:
129155
case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
130156
return snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
157+
case SNDRV_TIMER_IOCTL_GPARAMS32:
158+
return snd_timer_user_gparams_compat(file, argp);
131159
case SNDRV_TIMER_IOCTL_INFO32:
132160
return snd_timer_user_info_compat(file, argp);
133161
case SNDRV_TIMER_IOCTL_STATUS32:

sound/firewire/dice/dice-stream.c

+4-10
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,12 @@ int snd_dice_stream_init_duplex(struct snd_dice *dice)
446446

447447
void snd_dice_stream_destroy_duplex(struct snd_dice *dice)
448448
{
449-
struct reg_params tx_params, rx_params;
450-
451-
snd_dice_transaction_clear_enable(dice);
449+
unsigned int i;
452450

453-
if (get_register_params(dice, &tx_params, &rx_params) == 0) {
454-
stop_streams(dice, AMDTP_IN_STREAM, &tx_params);
455-
stop_streams(dice, AMDTP_OUT_STREAM, &rx_params);
451+
for (i = 0; i < MAX_STREAMS; i++) {
452+
destroy_stream(dice, AMDTP_IN_STREAM, i);
453+
destroy_stream(dice, AMDTP_OUT_STREAM, i);
456454
}
457-
458-
release_resources(dice);
459-
460-
dice->substreams_counter = 0;
461455
}
462456

463457
void snd_dice_stream_update_duplex(struct snd_dice *dice)

sound/pci/hda/hda_intel.c

+4
Original file line numberDiff line numberDiff line change
@@ -2361,6 +2361,10 @@ static const struct pci_device_id azx_ids[] = {
23612361
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
23622362
{ PCI_DEVICE(0x1002, 0xaae8),
23632363
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2364+
{ PCI_DEVICE(0x1002, 0xaae0),
2365+
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2366+
{ PCI_DEVICE(0x1002, 0xaaf0),
2367+
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
23642368
/* VIA VT8251/VT8237A */
23652369
{ PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
23662370
/* VIA GFX VT7122/VX900 */

sound/pci/hda/patch_realtek.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -4759,6 +4759,7 @@ enum {
47594759
ALC255_FIXUP_DELL_SPK_NOISE,
47604760
ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
47614761
ALC280_FIXUP_HP_HEADSET_MIC,
4762+
ALC221_FIXUP_HP_FRONT_MIC,
47624763
};
47634764

47644765
static const struct hda_fixup alc269_fixups[] = {
@@ -5401,6 +5402,13 @@ static const struct hda_fixup alc269_fixups[] = {
54015402
.chained = true,
54025403
.chain_id = ALC269_FIXUP_HEADSET_MIC,
54035404
},
5405+
[ALC221_FIXUP_HP_FRONT_MIC] = {
5406+
.type = HDA_FIXUP_PINS,
5407+
.v.pins = (const struct hda_pintbl[]) {
5408+
{ 0x19, 0x02a19020 }, /* Front Mic */
5409+
{ }
5410+
},
5411+
},
54045412
};
54055413

54065414
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5506,6 +5514,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
55065514
SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
55075515
SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
55085516
SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
5517+
SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
55095518
SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
55105519
SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
55115520
SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -6406,6 +6415,7 @@ enum {
64066415
ALC668_FIXUP_AUTO_MUTE,
64076416
ALC668_FIXUP_DELL_DISABLE_AAMIX,
64086417
ALC668_FIXUP_DELL_XPS13,
6418+
ALC662_FIXUP_ASUS_Nx50,
64096419
};
64106420

64116421
static const struct hda_fixup alc662_fixups[] = {
@@ -6646,6 +6656,12 @@ static const struct hda_fixup alc662_fixups[] = {
66466656
.type = HDA_FIXUP_FUNC,
66476657
.v.func = alc_fixup_bass_chmap,
66486658
},
6659+
[ALC662_FIXUP_ASUS_Nx50] = {
6660+
.type = HDA_FIXUP_FUNC,
6661+
.v.func = alc_fixup_auto_mute_via_amp,
6662+
.chained = true,
6663+
.chain_id = ALC662_FIXUP_BASS_1A
6664+
},
66496665
};
66506666

66516667
static const struct snd_pci_quirk alc662_fixup_tbl[] = {
@@ -6668,8 +6684,9 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
66686684
SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
66696685
SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
66706686
SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
6671-
SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
6687+
SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
66726688
SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
6689+
SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
66736690
SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
66746691
SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
66756692
SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),

sound/usb/quirks.c

+4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
150150
usb_audio_err(chip, "cannot memdup\n");
151151
return -ENOMEM;
152152
}
153+
INIT_LIST_HEAD(&fp->list);
153154
if (fp->nr_rates > MAX_NR_RATES) {
154155
kfree(fp);
155156
return -EINVAL;
@@ -193,6 +194,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
193194
return 0;
194195

195196
error:
197+
list_del(&fp->list); /* unlink for avoiding double-free */
196198
kfree(fp);
197199
kfree(rate_table);
198200
return err;
@@ -469,6 +471,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
469471
fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
470472
fp->datainterval = 0;
471473
fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
474+
INIT_LIST_HEAD(&fp->list);
472475

473476
switch (fp->maxpacksize) {
474477
case 0x120:
@@ -492,6 +495,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
492495
? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
493496
err = snd_usb_add_audio_stream(chip, stream, fp);
494497
if (err < 0) {
498+
list_del(&fp->list); /* unlink for avoiding double-free */
495499
kfree(fp);
496500
return err;
497501
}

sound/usb/stream.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits,
316316
/*
317317
* add this endpoint to the chip instance.
318318
* if a stream with the same endpoint already exists, append to it.
319-
* if not, create a new pcm stream.
319+
* if not, create a new pcm stream. note, fp is added to the substream
320+
* fmt_list and will be freed on the chip instance release. do not free
321+
* fp or do remove it from the substream fmt_list to avoid double-free.
320322
*/
321323
int snd_usb_add_audio_stream(struct snd_usb_audio *chip,
322324
int stream,
@@ -677,6 +679,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
677679
* (fp->maxpacksize & 0x7ff);
678680
fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no);
679681
fp->clock = clock;
682+
INIT_LIST_HEAD(&fp->list);
680683

681684
/* some quirks for attributes here */
682685

@@ -725,6 +728,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
725728
dev_dbg(&dev->dev, "%u:%d: add audio endpoint %#x\n", iface_no, altno, fp->endpoint);
726729
err = snd_usb_add_audio_stream(chip, stream, fp);
727730
if (err < 0) {
731+
list_del(&fp->list); /* unlink for avoiding double-free */
728732
kfree(fp->rate_table);
729733
kfree(fp->chmap);
730734
kfree(fp);

0 commit comments

Comments
 (0)