Merge "msm: ipa: Introduce additional NULL checks"

This commit is contained in:
QCTECMDR Service
2025-04-24 02:22:47 -07:00
committed by Gerrit - the friendly Code Review server

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2023, 2025 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include "ipa_i.h"
@@ -51,6 +51,13 @@ alloc:
list_for_each_entry(entry, &ipa3_ctx->hdr_tbl[loc].head_hdr_entry_list, link) {
IPADBG_LOW("hdr of len %d ofst=%d\n", entry->hdr_len,
entry->offset_entry->offset);
/* Safety check for pointer and header length to avoid dangerous overflow in HW */
if (unlikely(!entry->offset_entry ||
entry->hdr_len > ipa_hdr_bin_sz[IPA_HDR_BIN_MAX - 1])) {
IPAERR_RL("Invalid hdr entry\n");
return -EINVAL;
}
ipahal_cp_hdr_to_hw_buff(mem->base, entry->offset_entry->offset,
entry->hdr, entry->hdr_len);
}