11// SPDX-License-Identifier: GPL-2.0-only
22/*
33 * Copyright (c) 2021, The Linux Foundation. All rights reserved.
4- * Copyright (c) 2022-2025, Qualcomm Innovation Center , Inc. All rights reserved .
4+ * Copyright (c) Qualcomm Technologies , Inc. and/or its subsidiaries .
55 */
66
77#include <linux/mutex.h>
@@ -137,6 +137,13 @@ static int cam_cre_mgr_process_cmd_io_buf_req(struct cam_cre_hw_mgr *hw_mgr,
137137 struct cam_buf_io_cfg * io_cfg_ptr = NULL ;
138138 struct cam_cre_io_buf_info * acq_io_buf ;
139139
140+ if (!ctx_data -> cre_acquire .batch_size ||
141+ (ctx_data -> cre_acquire .batch_size > CRE_MAX_BATCH_SIZE )) {
142+ CAM_ERR (CAM_CRE , "Invalid batch_size: %u ctx id: %u max_batch_size: %u" ,
143+ ctx_data -> cre_acquire .batch_size , ctx_data -> ctx_id , CRE_MAX_BATCH_SIZE );
144+ return - EINVAL ;
145+ }
146+
140147 io_cfg_ptr = (struct cam_buf_io_cfg * )((uint32_t * )& packet -> payload_flex +
141148 packet -> io_configs_offset / 4 );
142149
@@ -163,6 +170,17 @@ static int cam_cre_mgr_process_cmd_io_buf_req(struct cam_cre_hw_mgr *hw_mgr,
163170 }
164171
165172 io_buf = cre_request -> io_buf [i ][j ];
173+
174+ if (!acq_io_buf -> num_planes ||
175+ (acq_io_buf -> num_planes > CAM_PACKET_MAX_PLANES )) {
176+ CAM_ERR (CAM_CRE ,
177+ "i %d j %d res_type %d Invalid num_planes: %u ctx id: %u max_planes: %u" ,
178+ i , j , acq_io_buf -> res_id , acq_io_buf -> num_planes ,
179+ ctx_data -> ctx_id , CAM_PACKET_MAX_PLANES );
180+ cam_cre_free_io_config (cre_request );
181+ return - EINVAL ;
182+ }
183+
166184 io_buf -> num_planes = acq_io_buf -> num_planes ;
167185 io_buf -> resource_type = acq_io_buf -> res_id ;
168186 io_buf -> direction = acq_io_buf -> direction ;
0 commit comments