diff mbox

ASoC: simple_card_utils: fix fallback when "label" property isn't present

Message ID 20170829155122.28606-1-l.stach@pengutronix.de (mailing list archive)
State Accepted
Commit 1b4a56cd7f5c2f835ffae2a8204fb95597269b10
Headers show

Commit Message

Lucas Stach Aug. 29, 2017, 3:51 p.m. UTC
snd_soc_of_parse_card_name() doesn't return an error if the requested
property isn't present, but silently fails to fill the card name. This can
not be changed, as it is a backwards compatibility measure itself.

We can not rely on the return value of this function alone, but must check
if the card name has been filled sucessfully when deciding to skip the
fallback path, which is in place for existing users.

Fixes: dedfaa1eedc7 (ASoC: simple-card-utils: enable "label" on
                     asoc_simple_card_parse_card_name)
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
This may be applied instead of the revert I just sent. After examining the
function more closely, the fix seems easy enough to go into 4.13 final.
---
 sound/soc/generic/simple-card-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kuninori Morimoto Aug. 30, 2017, 12:02 a.m. UTC | #1
Hi Lucas

> snd_soc_of_parse_card_name() doesn't return an error if the requested
> property isn't present, but silently fails to fill the card name. This can
> not be changed, as it is a backwards compatibility measure itself.
> 
> We can not rely on the return value of this function alone, but must check
> if the card name has been filled sucessfully when deciding to skip the
> fallback path, which is in place for existing users.
> 
> Fixes: dedfaa1eedc7 (ASoC: simple-card-utils: enable "label" on
>                      asoc_simple_card_parse_card_name)
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> This may be applied instead of the revert I just sent. After examining the
> function more closely, the fix seems easy enough to go into 4.13 final.

Yes, indeed.
Thanks

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>


Best regards
---
Kuninori Morimoto
diff mbox

Patch

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 7d7ab4aee42e..d72f7d58102f 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -132,7 +132,7 @@  int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
 
 	/* Parse the card name from DT */
 	ret = snd_soc_of_parse_card_name(card, "label");
-	if (ret < 0) {
+	if (ret < 0 || !card->name) {
 		char prop[128];
 
 		snprintf(prop, sizeof(prop), "%sname", prefix);