]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: sdw_utils: Remove dead code in asoc_sdw_ti_add_tac5xx2_routes()
authorNiranjan H Y <niranjan.hy@ti.com>
Wed, 13 May 2026 01:55:42 +0000 (07:25 +0530)
committerMark Brown <broonie@kernel.org>
Thu, 14 May 2026 00:50:57 +0000 (09:50 +0900)
Remove unnecessary checks for scnprintf() return values in
asoc_sdw_ti_add_tac5xx2_routes(). The function scnprintf() never
returns negative values and cannot return zero given the format
strings used ("%s SPK_L" and "%s SPK_R").

The existing length validation at line 110 already ensures that
name_prefix won't cause buffer overflow, and scnprintf() guarantees
null-termination even in case of truncation.

Fixes: e812de61e9a0 ("ASoC: sdw_utils: TI amp utility for tac5xx2 family")
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/linux-sound/agF8GBcHYUaGJbXY@stanley.mountain/
Signed-off-by: Niranjan H Y <niranjan.hy@ti.com>
Link: https://patch.msgid.link/20260513015542.2420-1-niranjan.hy@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sdw_utils/soc_sdw_ti_amp.c

index f156116fbeb652bc65e7f8952b73ede2f3f74085..d0ae5d7efe8f71fe67d05587de1b0d493eecbdd5 100644 (file)
@@ -105,18 +105,12 @@ static int asoc_sdw_ti_add_tac5xx2_routes(struct snd_soc_dapm_context *dapm,
        struct snd_soc_dapm_route routes[2];
        char left_widget[TAC5XX2_WIDGET_NAME_MAX];
        char right_widget[TAC5XX2_WIDGET_NAME_MAX];
-       int ret;
 
        if (strlen(name_prefix) > (TAC5XX2_WIDGET_NAME_MAX - 7))
                return -ENAMETOOLONG;
 
-       ret = scnprintf(left_widget, sizeof(left_widget), "%s SPK_L", name_prefix);
-       if (ret <= 0)
-               return -EINVAL;
-
-       ret = scnprintf(right_widget, sizeof(right_widget), "%s SPK_R", name_prefix);
-       if (ret <= 0)
-               return -EINVAL;
+       scnprintf(left_widget, sizeof(left_widget), "%s SPK_L", name_prefix);
+       scnprintf(right_widget, sizeof(right_widget), "%s SPK_R", name_prefix);
 
        routes[0] = (struct snd_soc_dapm_route){"Left Spk", NULL, left_widget};
        routes[1] = (struct snd_soc_dapm_route){"Right Spk", NULL, right_widget};