[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240619165621.47f2b3b2@bootlin.com>
Date: Wed, 19 Jun 2024 16:56:21 +0200
From: Herve Codina <herve.codina@...tlin.com>
To: Igor Artemiev <Igor.A.Artemiev@...t.ru>
Cc: Takashi Iwai <tiwai@...e.com>, Liam Girdwood <lgirdwood@...il.com>, Mark
Brown <broonie@...nel.org>, Jaroslav Kysela <perex@...ex.cz>, Kuninori
Morimoto <kuninori.morimoto.gx@...esas.com>, Linus Walleij
<linus.walleij@...aro.org>, Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error
handling in simple_util_init_jack()
Hi Igor,
On Wed, 19 Jun 2024 17:24:32 +0300
Igor Artemiev <Igor.A.Artemiev@...t.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@...t.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@...tlin.com>
Best regards,
Hervé
Powered by blists - more mailing lists