* [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack()
@ 2024-06-19 14:24 Igor Artemiev
2024-06-19 14:56 ` Herve Codina
2024-06-19 15:06 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Igor Artemiev @ 2024-06-19 14:24 UTC (permalink / raw)
To: Takashi Iwai
Cc: Igor Artemiev, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Kuninori Morimoto, Herve Codina, Linus Walleij,
Uwe Kleine-König, linux-sound, linux-kernel, lvc-project
Currently, if snd_soc_card_jack_new_pins() or snd_soc_jack_add_gpios()
fails, the function continues execution without handling the error.
This can lead to unexpected behavior and potential crashes.
This patch fixes the problem by checking the return value
of these functions.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Igor Artemiev <Igor.A.Artemiev@mcst.ru>
---
sound/soc/generic/simple-card-utils.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 81077d16d22f..5da0c13858ad 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -784,10 +784,14 @@ int simple_util_init_jack(struct snd_soc_card *card,
sjack->gpio.desc = desc;
sjack->gpio.debounce_time = 150;
- snd_soc_card_jack_new_pins(card, pin_name, mask, &sjack->jack,
+ error = snd_soc_card_jack_new_pins(card, pin_name, mask, &sjack->jack,
&sjack->pin, 1);
+ if (error)
+ return error;
- snd_soc_jack_add_gpios(&sjack->jack, 1, &sjack->gpio);
+ error = snd_soc_jack_add_gpios(&sjack->jack, 1, &sjack->gpio);
+ if (error)
+ return error;
}
return 0;
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack()
2024-06-19 14:24 [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack() Igor Artemiev
@ 2024-06-19 14:56 ` Herve Codina
2024-06-19 15:06 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Herve Codina @ 2024-06-19 14:56 UTC (permalink / raw)
To: Igor Artemiev
Cc: Takashi Iwai, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Kuninori Morimoto, Linus Walleij, Uwe Kleine-König,
linux-sound, linux-kernel, lvc-project
Hi Igor,
On Wed, 19 Jun 2024 17:24:32 +0300
Igor Artemiev <Igor.A.Artemiev@mcst.ru> wrote:
> Currently, if snd_soc_card_jack_new_pins() or snd_soc_jack_add_gpios()
> fails, the function continues execution without handling the error.
> This can lead to unexpected behavior and potential crashes.
>
> This patch fixes the problem by checking the return value
> of these functions.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Igor Artemiev <Igor.A.Artemiev@mcst.ru>
> ---
> sound/soc/generic/simple-card-utils.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
> index 81077d16d22f..5da0c13858ad 100644
> --- a/sound/soc/generic/simple-card-utils.c
> +++ b/sound/soc/generic/simple-card-utils.c
> @@ -784,10 +784,14 @@ int simple_util_init_jack(struct snd_soc_card *card,
> sjack->gpio.desc = desc;
> sjack->gpio.debounce_time = 150;
>
> - snd_soc_card_jack_new_pins(card, pin_name, mask, &sjack->jack,
> + error = snd_soc_card_jack_new_pins(card, pin_name, mask, &sjack->jack,
> &sjack->pin, 1);
> + if (error)
> + return error;
>
> - snd_soc_jack_add_gpios(&sjack->jack, 1, &sjack->gpio);
> + error = snd_soc_jack_add_gpios(&sjack->jack, 1, &sjack->gpio);
> + if (error)
> + return error;
> }
>
> return 0;
Looks correct for me.
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Best regards,
Hervé
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack()
2024-06-19 14:24 [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack() Igor Artemiev
2024-06-19 14:56 ` Herve Codina
@ 2024-06-19 15:06 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-06-19 15:06 UTC (permalink / raw)
To: Igor Artemiev
Cc: Takashi Iwai, Liam Girdwood, Jaroslav Kysela, Kuninori Morimoto,
Herve Codina, Linus Walleij, Uwe Kleine-König, linux-sound,
linux-kernel, lvc-project
[-- Attachment #1: Type: text/plain, Size: 476 bytes --]
On Wed, Jun 19, 2024 at 05:24:32PM +0300, Igor Artemiev wrote:
> Currently, if snd_soc_card_jack_new_pins() or snd_soc_jack_add_gpios()
> fails, the function continues execution without handling the error.
> This can lead to unexpected behavior and potential crashes.
This just looks like some static checker thing, I'm just seeing a bald
assertation about issues and crashes with no analysis about what those
might be. TBH I'd expect this to make things worse not better.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-19 15:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 14:24 [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack() Igor Artemiev
2024-06-19 14:56 ` Herve Codina
2024-06-19 15:06 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox