Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75d688e8 authored by Atish Kumar Patra's avatar Atish Kumar Patra
Browse files

soc: qcom: glink: Update to avoid invalid pointer access



Invalid pointer access happens if invalid edge name is passed to the find
transport function.

Update find transport function to avoid invalid pointer access and return
proper error in case of invalid edge name.

Change-Id: I7d14e73f438ef3e055c5d3251c8e2b2e1beacada
Signed-off-by: default avatarAtish Kumar Patra <apatra@codeaurora.org>
parent 028b35cc
Loading
Loading
Loading
Loading
+25 −17
Original line number Diff line number Diff line
@@ -1355,29 +1355,37 @@ static struct glink_core_xprt_ctx *find_open_transport(const char *edge,
	*best_id = USHRT_MAX;

	mutex_lock(&transport_list_lock_lha0);
	list_for_each_entry(xprt, &transport_list, list_node)
		if (!strcmp(edge, xprt->edge)) {
	list_for_each_entry(xprt, &transport_list, list_node) {
		if (strcmp(edge, xprt->edge))
			continue;
		if (first) {
			first = false;
			ret = NULL;
		}
			if (xprt_is_fully_opened(xprt)) {
		if (!xprt_is_fully_opened(xprt))
			continue;

		if (xprt->id < *best_id) {
			*best_id = xprt->id;
			best_xprt = xprt;
		}

				if (name && !strcmp(name, xprt->name))
		/*
		 * Braces are required in this instacne because the else will
		 * attach to the wrong if otherwise.
		 */
		if (name) {
			if (!strcmp(name, xprt->name))
				ret = xprt;
		} else {
			ret = best_xprt;
		}
	}

	mutex_unlock(&transport_list_lock_lha0);

	if (name && !ret)
	if (IS_ERR_OR_NULL(ret))
		return ret;
	if (!name)
		return best_xprt;
	if (!initial_xprt)
		*best_id = ret->id;