Commit 8f4b4db7 authored by Michael Scott's avatar Michael Scott Committed by Anas Nashif
Browse files

net: lwm2m: fix possible dereference in RD client



While looping through possible lwm2m_ctx matches, we're referencing
remote before checking that the context itself is valid.

Also, reduce indentation issues.

Signed-off-by: default avatarMichael Scott <michael@opensourcefoundries.com>
parent e0b8d172
Loading
Loading
Loading
Loading
+24 −21
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017 Linaro Limited
 * Copyright (c) 2017 Open Source Foundries Limited.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
@@ -163,8 +164,11 @@ static int find_clients_index(const struct sockaddr *addr)
	struct sockaddr *remote;

	for (i = 0; i < client_count; i++) {
		if (!clients[i].ctx) {
			continue;
		}

		remote = &clients[i].ctx->net_app_ctx.default_ctx->remote;
		if (clients[i].ctx) {
		if (remote->sa_family != addr->sa_family) {
			continue;
		}
@@ -191,7 +195,6 @@ static int find_clients_index(const struct sockaddr *addr)
		}
#endif
	}
	}

	return index;
}