@@ -3056,6 +3056,7 @@ static int hwsim_register_received_nl(struct sk_buff *skb_2,
3056
3056
static int hwsim_new_radio_nl (struct sk_buff * msg , struct genl_info * info )
3057
3057
{
3058
3058
struct hwsim_new_radio_params param = { 0 };
3059
+ const char * hwname = NULL ;
3059
3060
3060
3061
param .reg_strict = info -> attrs [HWSIM_ATTR_REG_STRICT_REG ];
3061
3062
param .p2p_device = info -> attrs [HWSIM_ATTR_SUPPORT_P2P_DEVICE ];
@@ -3069,8 +3070,14 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
3069
3070
if (info -> attrs [HWSIM_ATTR_NO_VIF ])
3070
3071
param .no_vif = true;
3071
3072
3072
- if (info -> attrs [HWSIM_ATTR_RADIO_NAME ])
3073
- param .hwname = nla_data (info -> attrs [HWSIM_ATTR_RADIO_NAME ]);
3073
+ if (info -> attrs [HWSIM_ATTR_RADIO_NAME ]) {
3074
+ hwname = kasprintf (GFP_KERNEL , "%.*s" ,
3075
+ nla_len (info -> attrs [HWSIM_ATTR_RADIO_NAME ]),
3076
+ (char * )nla_data (info -> attrs [HWSIM_ATTR_RADIO_NAME ]));
3077
+ if (!hwname )
3078
+ return - ENOMEM ;
3079
+ param .hwname = hwname ;
3080
+ }
3074
3081
3075
3082
if (info -> attrs [HWSIM_ATTR_USE_CHANCTX ])
3076
3083
param .use_chanctx = true;
@@ -3098,11 +3105,15 @@ static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
3098
3105
s64 idx = -1 ;
3099
3106
const char * hwname = NULL ;
3100
3107
3101
- if (info -> attrs [HWSIM_ATTR_RADIO_ID ])
3108
+ if (info -> attrs [HWSIM_ATTR_RADIO_ID ]) {
3102
3109
idx = nla_get_u32 (info -> attrs [HWSIM_ATTR_RADIO_ID ]);
3103
- else if (info -> attrs [HWSIM_ATTR_RADIO_NAME ])
3104
- hwname = (void * )nla_data (info -> attrs [HWSIM_ATTR_RADIO_NAME ]);
3105
- else
3110
+ } else if (info -> attrs [HWSIM_ATTR_RADIO_NAME ]) {
3111
+ hwname = kasprintf (GFP_KERNEL , "%.*s" ,
3112
+ nla_len (info -> attrs [HWSIM_ATTR_RADIO_NAME ]),
3113
+ (char * )nla_data (info -> attrs [HWSIM_ATTR_RADIO_NAME ]));
3114
+ if (!hwname )
3115
+ return - ENOMEM ;
3116
+ } else
3106
3117
return - EINVAL ;
3107
3118
3108
3119
spin_lock_bh (& hwsim_radio_lock );
@@ -3111,7 +3122,8 @@ static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
3111
3122
if (data -> idx != idx )
3112
3123
continue ;
3113
3124
} else {
3114
- if (strcmp (hwname , wiphy_name (data -> hw -> wiphy )))
3125
+ if (!hwname ||
3126
+ strcmp (hwname , wiphy_name (data -> hw -> wiphy )))
3115
3127
continue ;
3116
3128
}
3117
3129
@@ -3122,10 +3134,12 @@ static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
3122
3134
spin_unlock_bh (& hwsim_radio_lock );
3123
3135
mac80211_hwsim_del_radio (data , wiphy_name (data -> hw -> wiphy ),
3124
3136
info );
3137
+ kfree (hwname );
3125
3138
return 0 ;
3126
3139
}
3127
3140
spin_unlock_bh (& hwsim_radio_lock );
3128
3141
3142
+ kfree (hwname );
3129
3143
return - ENODEV ;
3130
3144
}
3131
3145
0 commit comments