Skip to content

Commit 3aa0c86

Browse files
jukkarkartben
authored andcommitted
net: wifi_cred: Check null before access
We must do null check before trying to access the fields. Fixes #81980 Coverify-CID: 434549 Signed-off-by: Jukka Rissanen <[email protected]>
1 parent b4fb833 commit 3aa0c86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/net/lib/wifi_credentials/wifi_credentials.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal
154154
{
155155
int ret;
156156

157-
if (creds->header.ssid_len > WIFI_SSID_MAX_LEN || creds->header.ssid_len == 0) {
158-
LOG_ERR("Cannot set WiFi credentials, SSID has invalid format");
157+
if (creds == NULL) {
158+
LOG_ERR("Cannot set WiFi credentials, provided struct pointer cannot be NULL");
159159
return -EINVAL;
160160
}
161161

162-
if (creds == NULL) {
163-
LOG_ERR("Cannot set WiFi credentials, provided struct pointer cannot be NULL");
162+
if (creds->header.ssid_len > WIFI_SSID_MAX_LEN || creds->header.ssid_len == 0) {
163+
LOG_ERR("Cannot set WiFi credentials, SSID has invalid format");
164164
return -EINVAL;
165165
}
166166

0 commit comments

Comments
 (0)