Skip to contentSkip to conversation

ALSA: control: Avoid WARN() for symlink errors

PATCH Superseded Takashi Iwai 1 participant 2 messages Dec 9, 2024 Sound

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: control: Avoid WARN() for symlink errors

Using WARN() for showing the error of symlink creations don't give more information than telling that something goes wrong, since the usual code path is a lregister callback from each control element creation. More badly, the use of WARN() rather confuses fuzzer as if it were serious issues.

This patch downgrades the warning messages to use the normal pr_warn() instead of WARN(). For making it clearer, add the function name to the prefix, too.

Fixes a135dfb5de15 ("ALSA: led control - add sysfs kcontrol LED marking layer")
Reported-by [email protected]
---
 sound/core/control_led.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
sound/core/control_led.c +8 -4
index 65a1ebe87776..ab04edf7e9aa 100644
@@ -668,10 +668,14 @@ static void snd_ctl_led_sysfs_add(struct snd_card *card)
 			goto cerr;
 		led->cards[card->number] = led_card;
 		snprintf(link_name, sizeof(link_name), "led-%s", led->name);
-		WARN(sysfs_create_link(&card->ctl_dev->kobj, &led_card->dev.kobj, link_name),
-			"can't create symlink to controlC%i device\n", card->number);
-		WARN(sysfs_create_link(&led_card->dev.kobj, &card->card_dev.kobj, "card"),
-			"can't create symlink to card%i\n", card->number);
+		if (sysfs_create_link(&card->ctl_dev->kobj, &led_card->dev.kobj,
+				      link_name))
+			pr_warn("%s: can't create symlink to controlC%i device\n",
+				__func__, card->number);
+		if (sysfs_create_link(&led_card->dev.kobj, &card->card_dev.kobj,
+				      "card"))
+			pr_warn("%s: can't create symlink to card%i\n",
+				__func__, card->number);
 
 		continue;
 cerr:
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Takashi Iwai

Using WARN() for showing the error of symlink creations don't give more information than telling that something goes wrong, since the usual code path is a lregister callback from each control element creation. More badly, the use of WARN() rather confuses fuzzer as if it were serious issues.

This patch downgrades the warning messages to use the normal pr_warn() instead of WARN().

There is no reason to stick with the warning level. It'd be better with the normal dev_err(). Will resubmit v2.

Takashi