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 <quic_bmanoj@quicinc.com>
Signed-off-by: Meenu Raja Sundaram <quic_mrajasun@quicinc.com>
This commit is contained in:
Manoj Prabhu B 2023-07-11 16:47:18 +05:30
commit afe20da34b

View file

@ -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 <linux/err.h>
@ -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,