Skip to content

Commit

Permalink
drivers: modem: ublox-sara-r4: Fix dereference before null check
Browse files Browse the repository at this point in the history
Fixes #32916

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
  • Loading branch information
Xavier Chapron authored and galak committed Mar 17, 2021
1 parent 066be0a commit 30c9588
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/modem/ublox-sara-r4.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ static ssize_t send_socket_data(void *obj,
struct sockaddr *dst_addr = msg->msg_name;
size_t buf_len = 0;

if (!sock) {
return -EINVAL;
}

for (int i = 0; i < msg->msg_iovlen; i++) {
if (!msg->msg_iov[i].iov_base || msg->msg_iov[i].iov_len == 0) {
errno = EINVAL;
Expand All @@ -331,10 +335,6 @@ static ssize_t send_socket_data(void *obj,
dst_addr = &sock->dst;
}

if (!sock) {
return -EINVAL;
}

/*
* Binary and ASCII mode allows sending MDM_MAX_DATA_LENGTH bytes to
* the socket in one command
Expand Down

0 comments on commit 30c9588

Please sign in to comment.