From: Herve Codina <herve.codina@bootlin.com>
To: Igor Artemiev <Igor.A.Artemiev@mcst.ru>
Cc: "Takashi Iwai" <tiwai@suse.com>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Kuninori Morimoto" <kuninori.morimoto.gx@renesas.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [lvc-project] [PATCH] ASoC: simple-card-utils: Fix error handling in simple_util_init_jack()
Date: Wed, 19 Jun 2024 16:56:21 +0200 [thread overview]
Message-ID: <20240619165621.47f2b3b2@bootlin.com> (raw)
In-Reply-To: <20240619142432.573338-1-Igor.A.Artemiev@mcst.ru>
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é
next prev parent reply other threads:[~2024-06-19 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-06-19 15:06 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240619165621.47f2b3b2@bootlin.com \
--to=herve.codina@bootlin.com \
--cc=Igor.A.Artemiev@mcst.ru \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox