Skip to content

Commit 9b2a1d3

Browse files
committed
ASoC: codecs: Call strscpy() with correct size argument
JIRA: https://issues.redhat.com/browse/RHEL-118909 commit dcb8290 Author: Thorsten Blum <thorsten.blum@linux.dev> Date: Sun Aug 10 23:41:05 2025 +0200 ASoC: codecs: Call strscpy() with correct size argument 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> Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
1 parent 3868be4 commit 9b2a1d3

File tree

6 files changed

+17
-28
lines changed

6 files changed

+17
-28
lines changed

sound/soc/codecs/aw87390.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static int aw87390_profile_info(struct snd_kcontrol *kcontrol,
177177
{
178178
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
179179
struct aw87390 *aw87390 = snd_soc_component_get_drvdata(codec);
180-
char *prof_name, *name;
180+
char *prof_name;
181181
int count, ret;
182182

183183
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -194,17 +194,15 @@ static int aw87390_profile_info(struct snd_kcontrol *kcontrol,
194194
if (uinfo->value.enumerated.item >= count)
195195
uinfo->value.enumerated.item = count - 1;
196196

197-
name = uinfo->value.enumerated.name;
198197
count = uinfo->value.enumerated.item;
199198

200199
ret = aw87390_dev_get_prof_name(aw87390->aw_pa, count, &prof_name);
201200
if (ret) {
202-
strscpy(uinfo->value.enumerated.name, "null",
203-
strlen("null") + 1);
201+
strscpy(uinfo->value.enumerated.name, "null");
204202
return 0;
205203
}
206204

207-
strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
205+
strscpy(uinfo->value.enumerated.name, prof_name);
208206

209207
return 0;
210208
}

sound/soc/codecs/aw88081.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,12 +914,11 @@ static int aw88081_profile_info(struct snd_kcontrol *kcontrol,
914914

915915
ret = aw88081_dev_get_prof_name(aw88081->aw_pa, count, &prof_name);
916916
if (ret) {
917-
strscpy(uinfo->value.enumerated.name, "null",
918-
sizeof(uinfo->value.enumerated.name));
917+
strscpy(uinfo->value.enumerated.name, "null");
919918
return 0;
920919
}
921920

922-
strscpy(uinfo->value.enumerated.name, prof_name, sizeof(uinfo->value.enumerated.name));
921+
strscpy(uinfo->value.enumerated.name, prof_name);
923922

924923
return 0;
925924
}

sound/soc/codecs/aw88166.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ static int aw88166_profile_info(struct snd_kcontrol *kcontrol,
14781478
{
14791479
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
14801480
struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec);
1481-
char *prof_name, *name;
1481+
char *prof_name;
14821482
int count, ret;
14831483

14841484
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -1495,17 +1495,15 @@ static int aw88166_profile_info(struct snd_kcontrol *kcontrol,
14951495
if (uinfo->value.enumerated.item >= count)
14961496
uinfo->value.enumerated.item = count - 1;
14971497

1498-
name = uinfo->value.enumerated.name;
14991498
count = uinfo->value.enumerated.item;
15001499

15011500
ret = aw88166_dev_get_prof_name(aw88166->aw_pa, count, &prof_name);
15021501
if (ret) {
1503-
strscpy(uinfo->value.enumerated.name, "null",
1504-
strlen("null") + 1);
1502+
strscpy(uinfo->value.enumerated.name, "null");
15051503
return 0;
15061504
}
15071505

1508-
strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
1506+
strscpy(uinfo->value.enumerated.name, prof_name);
15091507

15101508
return 0;
15111509
}

sound/soc/codecs/aw88261.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
819819
{
820820
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
821821
struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec);
822-
char *prof_name, *name;
822+
char *prof_name;
823823
int count, ret;
824824

825825
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -836,17 +836,15 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
836836
if (uinfo->value.enumerated.item >= count)
837837
uinfo->value.enumerated.item = count - 1;
838838

839-
name = uinfo->value.enumerated.name;
840839
count = uinfo->value.enumerated.item;
841840

842841
ret = aw88261_dev_get_prof_name(aw88261->aw_pa, count, &prof_name);
843842
if (ret) {
844-
strscpy(uinfo->value.enumerated.name, "null",
845-
strlen("null") + 1);
843+
strscpy(uinfo->value.enumerated.name, "null");
846844
return 0;
847845
}
848846

849-
strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
847+
strscpy(uinfo->value.enumerated.name, prof_name);
850848

851849
return 0;
852850
}

sound/soc/codecs/aw88395/aw88395.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol,
175175
{
176176
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
177177
struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec);
178-
char *prof_name, *name;
178+
char *prof_name;
179179
int count, ret;
180180

181181
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -192,17 +192,15 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol,
192192
if (uinfo->value.enumerated.item >= count)
193193
uinfo->value.enumerated.item = count - 1;
194194

195-
name = uinfo->value.enumerated.name;
196195
count = uinfo->value.enumerated.item;
197196

198197
ret = aw88395_dev_get_prof_name(aw88395->aw_pa, count, &prof_name);
199198
if (ret) {
200-
strscpy(uinfo->value.enumerated.name, "null",
201-
strlen("null") + 1);
199+
strscpy(uinfo->value.enumerated.name, "null");
202200
return 0;
203201
}
204202

205-
strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
203+
strscpy(uinfo->value.enumerated.name, prof_name);
206204

207205
return 0;
208206
}

sound/soc/codecs/aw88399.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ static int aw88399_profile_info(struct snd_kcontrol *kcontrol,
18311831
{
18321832
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
18331833
struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec);
1834-
char *prof_name, *name;
1834+
char *prof_name;
18351835
int count, ret;
18361836

18371837
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -1848,17 +1848,15 @@ static int aw88399_profile_info(struct snd_kcontrol *kcontrol,
18481848
if (uinfo->value.enumerated.item >= count)
18491849
uinfo->value.enumerated.item = count - 1;
18501850

1851-
name = uinfo->value.enumerated.name;
18521851
count = uinfo->value.enumerated.item;
18531852

18541853
ret = aw88399_dev_get_prof_name(aw88399->aw_pa, count, &prof_name);
18551854
if (ret) {
1856-
strscpy(uinfo->value.enumerated.name, "null",
1857-
strlen("null") + 1);
1855+
strscpy(uinfo->value.enumerated.name, "null");
18581856
return 0;
18591857
}
18601858

1861-
strscpy(name, prof_name, sizeof(uinfo->value.enumerated.name));
1859+
strscpy(uinfo->value.enumerated.name, prof_name);
18621860

18631861
return 0;
18641862
}

0 commit comments

Comments
 (0)