diff mbox series

ASoC: soc-card: Fix a reversed if condition

Message ID 155bb76e-dc57-4a5c-b0eb-acee5ebde9f4@moroto.mountain (mailing list archive)
State New
Headers show
Series ASoC: soc-card: Fix a reversed if condition | expand

Commit Message

Dan Carpenter April 8, 2024, 7:38 a.m. UTC
This if condition is reversed.  But fortunately, it has very little
impact on runtime behavior.

Fixes: ef7784e41db7 ("ASoC: soc-card: Add KUnit test case for snd_soc_card_get_kcontrol")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 sound/soc/soc-card-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown April 8, 2024, 12:43 p.m. UTC | #1
On Mon, Apr 08, 2024 at 10:38:02AM +0300, Dan Carpenter wrote:

>  	ret = snd_soc_register_card(priv->card);
> -	if (!ret)
> +	if (ret)
>  		return ret;
>  
>  	return 0;

Clearly a better fix here would just be to remove the conditional
entirely.
Dan Carpenter April 8, 2024, 12:50 p.m. UTC | #2
On Mon, Apr 08, 2024 at 01:43:09PM +0100, Mark Brown wrote:
> On Mon, Apr 08, 2024 at 10:38:02AM +0300, Dan Carpenter wrote:
> 
> >  	ret = snd_soc_register_card(priv->card);
> > -	if (!ret)
> > +	if (ret)
> >  		return ret;
> >  
> >  	return 0;
> 
> Clearly a better fix here would just be to remove the conditional
> entirely.

Hm...  Actually, it should be:

	if (ret) {
		put_device(priv->card_dev);
		return ret;
	}

	return 0;

Let me resend with that instead.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/sound/soc/soc-card-test.c b/sound/soc/soc-card-test.c
index 075c52fe82e5..a9fe7d243807 100644
--- a/sound/soc/soc-card-test.c
+++ b/sound/soc/soc-card-test.c
@@ -148,7 +148,7 @@  static int soc_card_test_case_init(struct kunit *test)
 	priv->card->owner = THIS_MODULE;
 
 	ret = snd_soc_register_card(priv->card);
-	if (!ret)
+	if (ret)
 		return ret;
 
 	return 0;