ASoC: nau8824: Fix semaphore unbalance at error paths
Subsystems (7)
Sasha Levin
maintainerPATCH 1/8 ASoC: nau8824: Fix semaphore unbalance at error paths
From: Takashi Iwai <[email protected]>
[ Upstream commit 5628560e90395d3812800a8e44a01c32ffa429ec ]
The semaphore of nau8824 wasn't properly unlocked at some error handling code paths, hence this may result in the unbalance (and potential lock-up). Fix them to handle the semaphore up properly.
--- sound/soc/codecs/nau8824.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
sound/soc/codecs/nau8824.c +10 -7
@@ -1015,6 +1015,7 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream,struct snd_soc_codec *codec = dai->codec;struct nau8824 *nau8824 =snd_soc_codec_get_drvdata (codec);unsigned int val_len =0 , osr, ctrl_val, bclk_fs, bclk_div; +int err = -EINVAL ;nau8824_sema_acquire (nau8824,HZ );
@@ -1031,7 +1032,7 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream, osr &=NAU8824_DAC_OVERSAMPLE_MASK ;if (nau8824_clock_check (nau8824, substream->stream, nau8824->fs, osr)) -return -EINVAL ; + goto error;regmap_update_bits (nau8824->regmap,NAU8824_REG_CLK_DIVIDER ,NAU8824_CLK_DAC_SRC_MASK , osr_dac_sel[osr].clk_src <<NAU8824_CLK_DAC_SRC_SFT );
@@ -1041,7 +1042,7 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream, osr &=NAU8824_ADC_SYNC_DOWN_MASK ;if (nau8824_clock_check (nau8824, substream->stream, nau8824->fs, osr)) -return -EINVAL ; + goto error;regmap_update_bits (nau8824->regmap,NAU8824_REG_CLK_DIVIDER ,NAU8824_CLK_ADC_SRC_MASK , osr_adc_sel[osr].clk_src <<NAU8824_CLK_ADC_SRC_SFT );
@@ -1062,7 +1063,7 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream,else if (bclk_fs <=256 ) bclk_div =0 ;else -return -EINVAL ; + goto error; regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_2, NAU8824_I2S_LRC_DIV_MASK | NAU8824_I2S_BLK_DIV_MASK,
@@ -1083,15 +1084,17 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream, val_len |=NAU8824_I2S_DL_32 ;break ;default : -return -EINVAL ; + goto error; }regmap_update_bits (nau8824->regmap,NAU8824_REG_PORT0_I2S_PCM_CTRL_1 ,NAU8824_I2S_DL_MASK , val_len); + err =0 ; + error:nau8824_sema_release (nau8824); -return 0 ; +return err; }static int nau8824_set_fmt (struct snd_soc_dai *dai,unsigned int fmt)
@@ -1100,8 +1103,6 @@ static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)struct nau8824 *nau8824 =snd_soc_codec_get_drvdata (codec);unsigned int ctrl1_val =0 , ctrl2_val =0 ; -nau8824_sema_acquire (nau8824,HZ ); -switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) {case SND_SOC_DAIFMT_CBM_CFM : ctrl2_val |=NAU8824_I2S_MS_MASTER ;
@@ -1143,6 +1144,8 @@ static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)return -EINVAL ; } +nau8824_sema_acquire (nau8824,HZ ); +regmap_update_bits (nau8824->regmap,NAU8824_REG_PORT0_I2S_PCM_CTRL_1 ,NAU8824_I2S_DF_MASK |NAU8824_I2S_BP_MASK |NAU8824_I2S_PCMB_EN , ctrl1_val);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 3/8 ALSA: hda/sigmatel: Keep power up while beep is enabled
From: Takashi Iwai <[email protected]>
[ Upstream commit 414d38ba871092aeac4ed097ac4ced89486646f7 ]
It seems that the beep playback doesn't work well on IDT codec devices when the codec auto-pm is enabled. Keep the power on while the beep switch is enabled.
--- sound/pci/hda/patch_sigmatel.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
sound/pci/hda/patch_sigmatel.c +22 -0
@@ -222,6 +222,7 @@ struct sigmatel_spec {/* beep widgets */ hda_nid_t anabeep_nid; +bool beep_power_on;/* SPDIF-out mux */ const char *const *spdif_labels;
@@ -4481,6 +4482,26 @@ static int stac_suspend(struct hda_codec *codec)stac_shutup (codec); return 0; } + +static int stac_check_power_status (struct hda_codec *codec,hda_nid_t nid) +{ +struct sigmatel_spec *spec = codec->spec; +int ret =snd_hda_gen_check_power_status (codec, nid); + +#ifdef CONFIG_SND_HDA_INPUT_BEEP +if (nid == spec->gen.beep_nid && codec->beep) { +if (codec->beep->enabled != spec->beep_power_on) { + spec->beep_power_on = codec->beep->enabled; +if (spec->beep_power_on) +snd_hda_power_up_pm (codec); +else +snd_hda_power_down_pm (codec); + } + ret |= spec->beep_power_on; + } +#endif +return ret; +}#else #define stac_suspend NULL#endif /* CONFIG_PM */
@@ -4493,6 +4514,7 @@ static const struct hda_codec_ops stac_patch_ops = { .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .suspend = stac_suspend, + .check_power_status = stac_check_power_status, #endif .reboot_notify = stac_shutup, };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 4/8 ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()
In reply to Sasha LevinFrom: Dongxiang Ke <[email protected]>
[ Upstream commit e53f47f6c1a56d2af728909f1cb894da6b43d9bf ]
There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and the number of it's interfaces less than 4, an out-of-bounds read bug occurs when parsing the interface descriptor for this device.
Fix this by checking the number of interfaces.
--- sound/usb/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/stream.c +1 -1
@@ -502,7 +502,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)* Dallas DS4201 workaround: It presents 5 altsettings, but the last * one misses syncpipe, and does not produce any sound. */ -if (chip->usb_id ==USB_ID (0x04fa ,0x4201 )) +if (chip->usb_id ==USB_ID (0x04fa ,0x4201 ) && num >=4 ) num =4 ;for (i =0 ; i < num; i++) {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 2/8 regulator: pfuze100: Fix the global-out-of-bounds access in pfuze100_regulator_probe()
In reply to Sasha LevinFrom: Xiaolei Wang <[email protected]>
[ Upstream commit 78e1e867f44e6bdc72c0e6a2609a3407642fb30b ]
The pfuze_chip::regulator_descs is an array of size PFUZE100_MAX_REGULATOR, the pfuze_chip::pfuze_regulators is the pointer to the real regulators of a specific device. The number of real regulator is supposed to be less than the PFUZE100_MAX_REGULATOR, so we should use the size of 'regulator_num * sizeof(struct pfuze_regulator)' in memcpy(). This fixes the out of bounds access bug reported by KASAN.
--- drivers/regulator/pfuze100-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/pfuze100-regulator.c +1 -1
@@ -614,7 +614,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000"));memcpy (pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators, -sizeof (pfuze_chip->regulator_descs)); + regulator_num *sizeof (struct pfuze_regulator )); ret =pfuze_parse_regulators_dt (pfuze_chip);if (ret)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 5/8 net: usb: qmi_wwan: add Quectel RM520N
In reply to Sasha LevinFrom: "jerry.meng" <[email protected]>
[ Upstream commit e1091e226a2bab4ded1fe26efba2aee1aab06450 ]
add support for Quectel RM520N which is based on Qualcomm SDX62 chip.
0x0801: DIAG + NMEA + AT + MODEM + RMNET
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 10 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=2c7c ProdID=0801 Rev= 5.04 S: Manufacturer=Quectel S: Product=RM520N-GL S: SerialNumber=384af524 C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=40 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=0f(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -1049,6 +1049,7 @@ static const struct usb_device_id products[] = { {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)}, /* Quectel EM160R-GL */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0801)}, /* Quectel RM520N *//* 3. Combined interface devices matching on interface number */ {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 7/8 MIPS: OCTEON: irq: Fix octeon_irq_force_ciu_mapping()
In reply to Sasha LevinFrom: Alexander Sverdlin <[email protected]>
[ Upstream commit ba912afbd611d3a5f22af247721a071ad1d5b9e0 ]
For irq_domain_associate() to work the virq descriptor has to be pre-allocated in advance. Otherwise the following happens:
WARNING: CPU: 0 PID: 0 at .../kernel/irq/irqdomain.c:527 irq_domain_associate+0x298/0x2e8
error: virq128 is not allocated
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.78-... #1
...
Call Trace:
[<ffffffff801344c4>] show_stack+0x9c/0x130
[<ffffffff80769550>] dump_stack+0x90/0xd0
[<ffffffff801576d0>] __warn+0x118/0x130
[<ffffffff80157734>] warn_slowpath_fmt+0x4c/0x70
[<ffffffff801b83c0>] irq_domain_associate+0x298/0x2e8
[<ffffffff80a43bb8>] octeon_irq_init_ciu+0x4c8/0x53c
[<ffffffff80a76cbc>] of_irq_init+0x1e0/0x388
[<ffffffff80a452cc>] init_IRQ+0x4c/0xf4
[<ffffffff80a3cc00>] start_kernel+0x404/0x698Use irq_alloc_desc_at() to avoid the above problem.
--- arch/mips/cavium-octeon/octeon-irq.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/mips/cavium-octeon/octeon-irq.c +10 -0
@@ -127,6 +127,16 @@ static void octeon_irq_free_cd(struct irq_domain *d, unsigned int irq)static int octeon_irq_force_ciu_mapping (struct irq_domain *domain,int irq,int line,int bit) { +struct device_node *of_node; +int ret; + + of_node =irq_domain_get_of_node (domain); +if (!of_node) +return -EINVAL ; + ret =irq_alloc_desc_at (irq,of_node_to_nid (of_node)); +if (ret <0 ) +return ret; +return irq_domain_associate (domain, irq, line <<6 | bit); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 8/8 mksysmap: Fix the mismatch of 'L0' symbols in System.map
In reply to Sasha LevinFrom: Youling Tang <[email protected]>
[ Upstream commit c17a2538704f926ee4d167ba625e09b1040d8439 ]
When System.map was generated, the kernel used mksysmap to filter the kernel symbols, we need to filter "L0" symbols in LoongArch architecture.
$ cat System.map | grep L0 9000000000221540 t L0
The L0 symbol exists in System.map, but not in .tmp_System.map. When "cmp -s System.map .tmp_System.map" will show "Inconsistent kallsyms data" error message in link-vmlinux.sh script.
--- scripts/mksysmap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mksysmap +1 -1
@@ -41,4 +41,4 @@ # so we just ignore them to let readprofile continue to work. # (At least sparc64 has __crc_ in the middle). -$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)' > $2 +$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)\|\( L0\)' > $2
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 6/8 scsi: mpt3sas: Fix use-after-free warning
In reply to Sasha LevinFrom: Sreekanth Reddy <[email protected]>
[ Upstream commit 991df3dd5144f2e6b1c38b8d20ed3d4d21e20b34 ]
Fix the following use-after-free warning which is observed during controller reset:
refcount_t: underflow; use-after-free.
WARNING: CPU: 23 PID: 5399 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -1
@@ -2804,6 +2804,7 @@ static struct fw_event_work *dequeue_next_fw_event(struct MPT3SAS_ADAPTER *ioc) fw_event =list_first_entry (&ioc->fw_event_list, struct fw_event_work, list);list_del_init (&fw_event->list); +fw_event_work_put (fw_event); }spin_unlock_irqrestore (&ioc->fw_event_lock, flags);
@@ -2840,7 +2841,6 @@ _scsih_fw_event_cleanup_queue(struct MPT3SAS_ADAPTER *ioc)if (cancel_work_sync (&fw_event->work))fw_event_work_put (fw_event); -fw_event_work_put (fw_event); } }
Signature · 1 line
2.35.1