|
1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | 2 | /* |
3 | 3 | * Copyright (c) 2017-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. |
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include <linux/types.h> |
@@ -263,6 +263,7 @@ void cam_packet_util_dump_patch_info(struct cam_packet *packet, |
263 | 263 | int32_t hdl; |
264 | 264 | uintptr_t cpu_addr = 0; |
265 | 265 | uint32_t *dst_cpu_addr; |
| 266 | + uint32_t dst_offset = 0; |
266 | 267 | uint32_t flags, buf_fd; |
267 | 268 | uint32_t value = 0; |
268 | 269 |
|
@@ -320,16 +321,26 @@ void cam_packet_util_dump_patch_info(struct cam_packet *packet, |
320 | 321 | return; |
321 | 322 | } |
322 | 323 |
|
| 324 | + dst_offset = patch_desc[i].dst_offset; |
| 325 | + |
| 326 | + if ((dst_buf_len < sizeof(uint32_t)) || |
| 327 | + ((dst_buf_len - sizeof(uint32_t)) < (size_t)dst_offset)) { |
| 328 | + CAM_ERR(CAM_UTIL, |
| 329 | + "Invalid dst buf patch at: %d src buf hdl 0x%llx src_buf address 0x%llx dst_buf_len 0x%zx, dst_offset 0x%x", |
| 330 | + i, patch_desc[i].src_buf_hdl, iova_addr, dst_buf_len, dst_offset); |
| 331 | + cam_mem_put_cpu_buf(patch_desc[i].dst_buf_hdl); |
| 332 | + return; |
| 333 | + } |
| 334 | + |
323 | 335 | dst_cpu_addr = (uint32_t *)cpu_addr; |
324 | | - dst_cpu_addr = (uint32_t *)((uint8_t *)dst_cpu_addr + |
325 | | - patch_desc[i].dst_offset); |
| 336 | + dst_cpu_addr = (uint32_t *)((uint8_t *)dst_cpu_addr + dst_offset); |
326 | 337 | value = *dst_cpu_addr; |
327 | 338 | CAM_INFO(CAM_UTIL, |
328 | 339 | "i = %d src_buf 0x%llx src_hdl 0x%x src_buf_with_offset 0x%llx src_size 0x%llx src_flags: %x dst %p dst_offset %u dst_hdl 0x%x value 0x%x", |
329 | 340 | i, iova_addr, patch_desc[i].src_buf_hdl, |
330 | 341 | (iova_addr + patch_desc[i].src_offset), |
331 | 342 | src_buf_size, flags, dst_cpu_addr, |
332 | | - patch_desc[i].dst_offset, |
| 343 | + dst_offset, |
333 | 344 | patch_desc[i].dst_buf_hdl, value); |
334 | 345 |
|
335 | 346 | if (!(*dst_cpu_addr)) |
|
0 commit comments