* [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls()
@ 2023-02-25 18:43 Dmitry Fomin
2023-02-25 18:43 ` [PATCH 2/2] ALSA: ice1712: Delete unreachable code " Dmitry Fomin
2023-03-03 13:31 ` [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked " Takashi Iwai
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Fomin @ 2023-02-25 18:43 UTC (permalink / raw)
To: Jaroslav Kysela
Cc: Dmitry Fomin, Takashi Iwai, alsa-devel, linux-kernel, lvc-project
If snd_ctl_add() fails in aureon_add_controls(), it immediately returns
and leaves ice->gpio_mutex locked. ice->gpio_mutex locks in
snd_ice1712_save_gpio_status and unlocks in
snd_ice1712_restore_gpio_status(ice).
It seems that the mutex is required only for aureon_cs8415_get(),
so snd_ice1712_restore_gpio_status(ice) can be placed
just after that. Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Dmitry Fomin <fomindmitriyfoma@mail.ru>
---
sound/pci/ice1712/aureon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 9a30f6d35d13..40a0e0095030 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1892,6 +1892,7 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
unsigned char id;
snd_ice1712_save_gpio_status(ice);
id = aureon_cs8415_get(ice, CS8415_ID);
+ snd_ice1712_restore_gpio_status(ice);
if (id != 0x41)
dev_info(ice->card->dev,
"No CS8415 chip. Skipping CS8415 controls.\n");
@@ -1909,7 +1910,6 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
kctl->id.device = ice->pcm->device;
}
}
- snd_ice1712_restore_gpio_status(ice);
}
return 0;
--
2.37.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] ALSA: ice1712: Delete unreachable code in aureon_add_controls()
2023-02-25 18:43 [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls() Dmitry Fomin
@ 2023-02-25 18:43 ` Dmitry Fomin
2023-03-03 13:31 ` [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked " Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Fomin @ 2023-02-25 18:43 UTC (permalink / raw)
To: Jaroslav Kysela
Cc: Dmitry Fomin, Takashi Iwai, alsa-devel, linux-kernel, lvc-project
If the check (id != 0x41) fails, then id == 0x41 and
the other check in 'else' branch also
fails: id & 0x0F = 0b01000001 & 0b00001111 = 0b00000001.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Dmitry Fomin <fomindmitriyfoma@mail.ru>
---
sound/pci/ice1712/aureon.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 9a30f6d35d13..aa24f826d91b 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1895,10 +1895,6 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
if (id != 0x41)
dev_info(ice->card->dev,
"No CS8415 chip. Skipping CS8415 controls.\n");
- else if ((id & 0x0F) != 0x01)
- dev_info(ice->card->dev,
- "Detected unsupported CS8415 rev. (%c)\n",
- (char)((id & 0x0F) + 'A' - 1));
else {
for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) {
struct snd_kcontrol *kctl;
--
2.37.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls()
2023-02-25 18:43 [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls() Dmitry Fomin
2023-02-25 18:43 ` [PATCH 2/2] ALSA: ice1712: Delete unreachable code " Dmitry Fomin
@ 2023-03-03 13:31 ` Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2023-03-03 13:31 UTC (permalink / raw)
To: Dmitry Fomin
Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel, lvc-project
On Sat, 25 Feb 2023 19:43:21 +0100,
Dmitry Fomin wrote:
>
> If snd_ctl_add() fails in aureon_add_controls(), it immediately returns
> and leaves ice->gpio_mutex locked. ice->gpio_mutex locks in
> snd_ice1712_save_gpio_status and unlocks in
> snd_ice1712_restore_gpio_status(ice).
>
> It seems that the mutex is required only for aureon_cs8415_get(),
> so snd_ice1712_restore_gpio_status(ice) can be placed
> just after that. Compile tested only.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Dmitry Fomin <fomindmitriyfoma@mail.ru>
Applied both patches now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-03 13:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-25 18:43 [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls() Dmitry Fomin
2023-02-25 18:43 ` [PATCH 2/2] ALSA: ice1712: Delete unreachable code " Dmitry Fomin
2023-03-03 13:31 ` [PATCH 1/2] ALSA: ice1712: Do not left ice->gpio_mutex locked " Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®