net: dns: Invalid memory access

Do not try to cancel query if the DNS query index is < 0.

Coverity-CID: 166770

Change-Id: I03c1f274453640d0ff80694628b8e8f18e8de900
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-04-07 22:22:34 +03:00
commit 9d74fd71b5

View file

@ -566,7 +566,7 @@ static void cb_recv(struct net_context *net_ctx,
i = get_slot_by_id(ctx, dns_id);
if (i < 0) {
goto cancel;
goto free_buf;
}
for (j = 0; j < CONFIG_DNS_RESOLVER_MAX_SERVERS; j++) {
@ -598,7 +598,6 @@ quit:
goto free_buf;
}
cancel:
if (k_delayed_work_remaining_get(&ctx->queries[i].timer) > 0) {
k_delayed_work_cancel(&ctx->queries[i].timer);
}