Skip to content

Commit fa703b4

Browse files
Fix nullptr dereference segfault in QNN runtime when op_package_options is null (#20759)
This PR fixes a nullptr dereference segmentation fault in Qualcomm QNN backend's runtime when 'op_package_options' is not present in the serialized metadata (which is common for standard models). It adds null-safety checks before dereferencing options in QnnManager.cpp and QnnBackendCommon.cpp. Fixes #20619.
1 parent 089b0d0 commit fa703b4

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

backends/qualcomm/runtime/QnnManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ QnnManager::QnnManager(
8484
"Enable shared buffer: %d", options->shared_buffer());
8585
QNN_EXECUTORCH_LOG_INFO(
8686
"The number of op packages: %d",
87-
options_->op_package_options()->op_package_infos()->size());
87+
options_->op_package_options() &&
88+
options_->op_package_options()->op_package_infos()
89+
? options_->op_package_options()->op_package_infos()->size()
90+
: 0);
8891
}
8992

9093
backend_params_ptr_ = std::make_unique<BackendConfigParameters>();

backends/qualcomm/runtime/backends/QnnBackendCommon.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ Error QnnBackend::Configure(
9494
return Error::Internal;
9595
}
9696

97-
if (op_package_options->op_package_infos()->size() > 0) {
97+
if (op_package_options && op_package_options->op_package_infos() &&
98+
op_package_options->op_package_infos()->size() > 0) {
9899
BackendRegisterOpPackage(op_package_options->op_package_infos());
99100
}
100101

0 commit comments

Comments
 (0)