@@ -1021,6 +1021,7 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
1021
1021
struct snd_soc_tplg_hdr * hdr )
1022
1022
{
1023
1023
struct snd_soc_dapm_context * dapm = & tplg -> comp -> dapm ;
1024
+ const size_t maxlen = SNDRV_CTL_ELEM_ID_NAME_MAXLEN ;
1024
1025
struct snd_soc_tplg_dapm_graph_elem * elem ;
1025
1026
struct snd_soc_dapm_route * route ;
1026
1027
int count , i ;
@@ -1044,38 +1045,27 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
1044
1045
tplg -> pos += sizeof (struct snd_soc_tplg_dapm_graph_elem );
1045
1046
1046
1047
/* validate routes */
1047
- if (strnlen (elem -> source , SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) ==
1048
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) {
1049
- ret = - EINVAL ;
1050
- break ;
1051
- }
1052
- if (strnlen (elem -> sink , SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) ==
1053
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) {
1054
- ret = - EINVAL ;
1055
- break ;
1056
- }
1057
- if (strnlen (elem -> control , SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) ==
1058
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) {
1048
+ if ((strnlen (elem -> source , maxlen ) == maxlen ) ||
1049
+ (strnlen (elem -> sink , maxlen ) == maxlen ) ||
1050
+ (strnlen (elem -> control , maxlen ) == maxlen )) {
1059
1051
ret = - EINVAL ;
1060
1052
break ;
1061
1053
}
1062
1054
1063
1055
route -> source = devm_kmemdup (tplg -> dev , elem -> source ,
1064
- min (strlen (elem -> source ),
1065
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN ),
1056
+ min (strlen (elem -> source ), maxlen ),
1066
1057
GFP_KERNEL );
1067
1058
route -> sink = devm_kmemdup (tplg -> dev , elem -> sink ,
1068
- min (strlen (elem -> sink ), SNDRV_CTL_ELEM_ID_NAME_MAXLEN ),
1059
+ min (strlen (elem -> sink ), maxlen ),
1069
1060
GFP_KERNEL );
1070
1061
if (!route -> source || !route -> sink ) {
1071
1062
ret = - ENOMEM ;
1072
1063
break ;
1073
1064
}
1074
1065
1075
- if (strnlen (elem -> control , SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) != 0 ) {
1066
+ if (strnlen (elem -> control , maxlen ) != 0 ) {
1076
1067
route -> control = devm_kmemdup (tplg -> dev , elem -> control ,
1077
- min (strlen (elem -> control ),
1078
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN ),
1068
+ min (strlen (elem -> control ), maxlen ),
1079
1069
GFP_KERNEL );
1080
1070
if (!route -> control ) {
1081
1071
ret = - ENOMEM ;
0 commit comments