From afe20da34be7cd24ef3bff5b1ff042402958a4d5 Mon Sep 17 00:00:00 2001 From: Manoj Prabhu B Date: Tue, 11 Jul 2023 16:47:18 +0530 Subject: [PATCH] memshare: Avoid accessing uninitialized nodes Prevent iterating over uninitialized memshare child nodes while handling client alloc and free requests. Change-Id: I421cd239bb999176e587ab0c06757d83485fad6e Signed-off-by: Manoj Prabhu B Signed-off-by: Meenu Raja Sundaram --- drivers/soc/qcom/memshare/msm_memshare.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soc/qcom/memshare/msm_memshare.c b/drivers/soc/qcom/memshare/msm_memshare.c index 6d1badcf1afd..43ca69072932 100644 --- a/drivers/soc/qcom/memshare/msm_memshare.c +++ b/drivers/soc/qcom/memshare/msm_memshare.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -104,7 +104,7 @@ static int check_client(int client_id, int proc, int request) int i = 0, rc; int found = DHMS_MEM_CLIENT_INVALID; - for (i = 0; i < MAX_CLIENTS; i++) { + for (i = 0; i < num_clients; i++) { if (memblock[i].client_id == client_id && memblock[i].peripheral == proc) { found = i; @@ -484,7 +484,7 @@ static void handle_alloc_generic_req(struct qmi_handle *handle, return; } - for (i = 0; i < MAX_CLIENTS; i++) { + for (i = 0; i < num_clients; i++) { if (memsh_child[i]->client_id == alloc_req->client_id) { client_node = memsh_child[i]; dev_info(memsh_drv->dev, @@ -577,7 +577,7 @@ static void handle_free_generic_req(struct qmi_handle *handle, flag = 1; } - for (i = 0; i < MAX_CLIENTS; i++) { + for (i = 0; i < num_clients; i++) { if (memsh_child[i]->client_id == free_req->client_id) { client_node = memsh_child[i]; dev_info(memsh_drv->dev,