net: tcp2: Check pointer before use in accept
The conn pointer NULL value was checked too late. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
74d459fb66
commit
e1f06e26b2
1 changed files with 8 additions and 5 deletions
|
@ -1068,14 +1068,17 @@ int net_tcp_accept(struct net_context *context, net_tcp_accept_cb_t cb,
|
||||||
struct sockaddr local_addr = { };
|
struct sockaddr local_addr = { };
|
||||||
u16_t local_port, remote_port;
|
u16_t local_port, remote_port;
|
||||||
|
|
||||||
NET_DBG("context: %p, tcp: %p, cb: %p", context, conn, cb);
|
if (!conn) {
|
||||||
|
|
||||||
conn->accept_cb = cb;
|
|
||||||
|
|
||||||
if (!conn || conn->state != TCP_LISTEN) {
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NET_DBG("context: %p, tcp: %p, cb: %p", context, conn, cb);
|
||||||
|
|
||||||
|
if (conn->state != TCP_LISTEN) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn->accept_cb = cb;
|
||||||
local_addr.sa_family = net_context_get_family(context);
|
local_addr.sa_family = net_context_get_family(context);
|
||||||
|
|
||||||
switch (local_addr.sa_family) {
|
switch (local_addr.sa_family) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue