]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: codecs: Call strscpy() with correct size argument
authorThorsten Blum <thorsten.blum@linux.dev>
Sun, 10 Aug 2025 21:41:05 +0000 (23:41 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 12 Aug 2025 11:05:56 +0000 (12:05 +0100)
In aw8xxxx_profile_info(), strscpy() is called with the length of the
source string "null" rather than the size of the destination buffer.

This is fine as long as the destination buffer is larger than the source
string, but we should still use the destination buffer size instead to
call strscpy() as intended. And since 'name' points to the fixed-size
buffer 'uinfo->value.enumerated.name', we can safely omit the size
argument and let strscpy() infer it using sizeof() and remove 'name'.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250810214144.1985-2-thorsten.blum@linux.dev
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/aw87390.c
sound/soc/codecs/aw88081.c
sound/soc/codecs/aw88166.c
sound/soc/codecs/aw88261.c
sound/soc/codecs/aw88395/aw88395.c
sound/soc/codecs/aw88399.c

index 110009616966acbbfb04fa9d2bedfe30e7cbd698..ef6f648569888c6ee30b005a37c570dad882b741 100644 (file)
@@ -177,7 +177,7 @@ static int aw87390_profile_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
        struct aw87390 *aw87390 = snd_soc_component_get_drvdata(codec);
-       char *prof_name, *name;
+       char *prof_name;
        int count, ret;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -194,17 +194,15 @@ static int aw87390_profile_info(struct snd_kcontrol *kcontrol,
        if (uinfo->value.enumerated.item >= count)
                uinfo->value.enumerated.item = count - 1;
 
-       name = uinfo->value.enumerated.name;
        count = uinfo->value.enumerated.item;
 
        ret = aw87390_dev_get_prof_name(aw87390->aw_pa, count, &prof_name);
        if (ret) {
-               strscpy(uinfo->value.enumerated.name, "null",
-                                               strlen("null") + 1);
+               strscpy(uinfo->value.enumerated.name, "null");
                return 0;
        }
 
-       strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
+       strscpy(uinfo->value.enumerated.name, prof_name);
 
        return 0;
 }
index 3dd8428f08cce9d03f8debf9388a96beedaae6e3..d61a7b8c5470fd658cf1b565e6fed849bb05e123 100644 (file)
@@ -914,12 +914,11 @@ static int aw88081_profile_info(struct snd_kcontrol *kcontrol,
 
        ret = aw88081_dev_get_prof_name(aw88081->aw_pa, count, &prof_name);
        if (ret) {
-               strscpy(uinfo->value.enumerated.name, "null",
-                                               sizeof(uinfo->value.enumerated.name));
+               strscpy(uinfo->value.enumerated.name, "null");
                return 0;
        }
 
-       strscpy(uinfo->value.enumerated.name, prof_name, sizeof(uinfo->value.enumerated.name));
+       strscpy(uinfo->value.enumerated.name, prof_name);
 
        return 0;
 }
index 4f76ebe11cc7ec8c679a56839272ca5a065164b6..28f62b991ef2b7b2c9bd51c242d9fd5760822128 100644 (file)
@@ -1478,7 +1478,7 @@ static int aw88166_profile_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
        struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec);
-       char *prof_name, *name;
+       char *prof_name;
        int count, ret;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -1495,17 +1495,15 @@ static int aw88166_profile_info(struct snd_kcontrol *kcontrol,
        if (uinfo->value.enumerated.item >= count)
                uinfo->value.enumerated.item = count - 1;
 
-       name = uinfo->value.enumerated.name;
        count = uinfo->value.enumerated.item;
 
        ret = aw88166_dev_get_prof_name(aw88166->aw_pa, count, &prof_name);
        if (ret) {
-               strscpy(uinfo->value.enumerated.name, "null",
-                                               strlen("null") + 1);
+               strscpy(uinfo->value.enumerated.name, "null");
                return 0;
        }
 
-       strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
+       strscpy(uinfo->value.enumerated.name, prof_name);
 
        return 0;
 }
index fb99871578c5a99dab9c4d852d27cd1c547a60b6..de11ae8dd9d9f793b30f7ce92db611ec4d156ef7 100644 (file)
@@ -819,7 +819,7 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
        struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec);
-       char *prof_name, *name;
+       char *prof_name;
        int count, ret;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -836,17 +836,15 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
        if (uinfo->value.enumerated.item >= count)
                uinfo->value.enumerated.item = count - 1;
 
-       name = uinfo->value.enumerated.name;
        count = uinfo->value.enumerated.item;
 
        ret = aw88261_dev_get_prof_name(aw88261->aw_pa, count, &prof_name);
        if (ret) {
-               strscpy(uinfo->value.enumerated.name, "null",
-                                               strlen("null") + 1);
+               strscpy(uinfo->value.enumerated.name, "null");
                return 0;
        }
 
-       strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
+       strscpy(uinfo->value.enumerated.name, prof_name);
 
        return 0;
 }
index aea44a199b98ee6e3e30917ba7dac65a4e7b0f98..fb563b4c697180e3768a9e7b798ab6f05c4a552d 100644 (file)
@@ -175,7 +175,7 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
        struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec);
-       char *prof_name, *name;
+       char *prof_name;
        int count, ret;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -192,17 +192,15 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol,
        if (uinfo->value.enumerated.item >= count)
                uinfo->value.enumerated.item = count - 1;
 
-       name = uinfo->value.enumerated.name;
        count = uinfo->value.enumerated.item;
 
        ret = aw88395_dev_get_prof_name(aw88395->aw_pa, count, &prof_name);
        if (ret) {
-               strscpy(uinfo->value.enumerated.name, "null",
-                                               strlen("null") + 1);
+               strscpy(uinfo->value.enumerated.name, "null");
                return 0;
        }
 
-       strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
+       strscpy(uinfo->value.enumerated.name, prof_name);
 
        return 0;
 }
index c23e70d64d0c165bbc24add9b0e1d349cf1d3e1f..58846feb013d13dd38dafa4ec86b4b50b941bfd0 100644 (file)
@@ -1831,7 +1831,7 @@ static int aw88399_profile_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
        struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec);
-       char *prof_name, *name;
+       char *prof_name;
        int count, ret;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -1848,17 +1848,15 @@ static int aw88399_profile_info(struct snd_kcontrol *kcontrol,
        if (uinfo->value.enumerated.item >= count)
                uinfo->value.enumerated.item = count - 1;
 
-       name = uinfo->value.enumerated.name;
        count = uinfo->value.enumerated.item;
 
        ret = aw88399_dev_get_prof_name(aw88399->aw_pa, count, &prof_name);
        if (ret) {
-               strscpy(uinfo->value.enumerated.name, "null",
-                                               strlen("null") + 1);
+               strscpy(uinfo->value.enumerated.name, "null");
                return 0;
        }
 
-       strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
+       strscpy(uinfo->value.enumerated.name, prof_name);
 
        return 0;
 }