p2p: check connected peer before processing request

Caught by static analysis, the dev->conn_peer pointer was being
dereferenced very early on without a NULL check, but further it
was being NULL checked. If there is a possibility of it being NULL
the check should be done much earlier.
This commit is contained in:
James Prestwood 2024-03-01 11:40:53 -08:00 committed by Denis Kenzior
parent 71a7190ed2
commit 795f57e816
1 changed files with 4 additions and 1 deletions

View File

@ -2310,6 +2310,9 @@ static void p2p_device_go_negotiation_req_cb(const struct mmpdu_header *mpdu,
if (!peer)
return;
if (!dev->conn_peer)
return;
if (body_len < 8)
return;
@ -2438,7 +2441,7 @@ static void p2p_device_go_negotiation_req_cb(const struct mmpdu_header *mpdu,
memcpy(dev->conn_peer_interface_addr, req_info.intended_interface_addr,
6);
if (dev->is_go && dev->conn_peer) {
if (dev->is_go) {
p2p_set_group_id(dev);
dev->conn_config_delay =