drivers: modem: quectel-bg9x: fix potential null pointer dereference
reorganize code so that null pointer check is done prior to accessing element. Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
This commit is contained in:
parent
c2339db996
commit
4b5a2b989e
|
@ -135,7 +135,7 @@ static int on_cmd_sockread_common(int socket_fd,
|
|||
struct modem_socket *sock = NULL;
|
||||
struct socket_read_data *sock_data;
|
||||
int ret, i;
|
||||
int socket_data_length = find_len(data->rx_buf->data);
|
||||
int socket_data_length;
|
||||
int bytes_to_skip;
|
||||
|
||||
if (!len) {
|
||||
|
@ -149,6 +149,8 @@ static int on_cmd_sockread_common(int socket_fd,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
socket_data_length = find_len(data->rx_buf->data);
|
||||
|
||||
/* No (or not enough) data available on the socket. */
|
||||
bytes_to_skip = digits(socket_data_length) + 2 + 4;
|
||||
if (socket_data_length <= 0) {
|
||||
|
|
Loading…
Reference in a new issue