lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 12 Apr 2024 14:02:20 +0100
From: Richard Fitzgerald <rf@...nsource.cirrus.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
CC: Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
        Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
        <linux-sound@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <kernel-janitors@...r.kernel.org>
Subject: Re: [PATCH v3] ASoC: soc-card: soc-card-test: Fix some error handling
 in init()

On 12/04/2024 13:07, Dan Carpenter wrote:
> There are two issues here:
> 1) The get_device() needs a matching put_device() on error paths.
> 2) The "if (!ret)" was supposed to be "if (ret)".
> 
> I re-arranged the code a bit to do the allocation before the
> get_device().
> 
> Fixes: ef7784e41db7 ("ASoC: soc-card: Add KUnit test case for snd_soc_card_get_kcontrol")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
> v2: add a put_device()
> v3: move the kunit_kzalloc() to avoid a second put_device().  Btw,
>      kunit_kzalloc() is cleaned up automatically.
> 
>   sound/soc/soc-card-test.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/soc-card-test.c b/sound/soc/soc-card-test.c
> index 075c52fe82e5..e4a4b101d743 100644
> --- a/sound/soc/soc-card-test.c
> +++ b/sound/soc/soc-card-test.c
> @@ -134,22 +134,24 @@ static int soc_card_test_case_init(struct kunit *test)
>   
>   	test->priv = priv;
>   
> +	priv->card = kunit_kzalloc(test, sizeof(*priv->card), GFP_KERNEL);
> +	if (!priv->card)
> +		return -ENOMEM;
> +
>   	priv->card_dev = kunit_device_register(test, "sound-soc-card-test");
>   	priv->card_dev = get_device(priv->card_dev);
>   	if (!priv->card_dev)
>   		return -ENODEV;
>   
> -	priv->card = kunit_kzalloc(test, sizeof(*priv->card), GFP_KERNEL);
> -	if (!priv->card)
> -		return -ENOMEM;
> -
>   	priv->card->name = "soc-card-test";
>   	priv->card->dev = priv->card_dev;
>   	priv->card->owner = THIS_MODULE;
>   
>   	ret = snd_soc_register_card(priv->card);
> -	if (!ret)
> +	if (ret) {
> +		put_device(priv->card_dev);
>   		return ret;
> +	}
>   
>   	return 0;
>   }
Reviewed-by: Richard Fitzgerald <rf@...nsource.cirrus.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ