Merged
fix(machine): null-check AllocDev result in Emulation AllocZero #5860
chaizhengtongAdd on Sep 2
fix(machine): null-check AllocDev result in Emulation AllocZero #5860
Merged
Merged fromchai-hw/pypto_chaifixemulationintocann/pyptomaster
chaizhengtongCollaborators
Sep 2
Sep 2


Pull Request has been successfully merged by CANN-robot.
(Thank you for chaizhengtong's contribution.)Sep 2 Created pull request, commit 7911aaab
atomgit-bot
Sep 2 Comments:
Sep 2 Comments:
变更摘要
该 PR 为 EmulationMemoryUtils::AllocZero 增加了空指针校验:在 AllocDev(size, nullptr) 返回的设备指针 devPtr 为 nullptr 时跳过 memset_s 清零操作,避免对空指针执行内存写入导致崩溃,修复 emulation 模式下内存分配失败场景下的安全隐患。改动仅涉及 framework/src/machine/runtime/memory_utils/emulation_memory_utils.h 一个文件。
主要改动
AllocZero空指针保护: 将原本无条件的memset_s(devPtr, size, 0, size)置于if (devPtr != nullptr)条件内,仅当AllocDev分配成功时才执行内存清零。- 失败路径安全返回: 当
AllocDev返回空指针时,AllocZero直接返回devPtr(即nullptr),由调用方处理分配失败,不再触发对空指针的写入。


Incorrect?
atomgit-bot
Sep 2 Comments:
Sep 2 Comments:
Sep 2 Added label: cann-cla/yes
CANN-robot
Sep 2 Comments:
Sep 2 Comments:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| framework/src/machine | ✅ jason_yuan_ye, gaoxingwang (2/2) | ✅ jason_yuan_ye (1/1) |
| repo-cann/pypto | ✅ jason_yuan_ye, gaoxingwang (2/2) | ✅ jason_yuan_ye (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
chai-hw, thanks for your pull request. All authors of the commits have signed the CLA. 👍


65 messages are collapsed here。 See more
Sep 4 Added label: approved
Sep 4 Resolved final issue
gaoxingwang
Sep 4 Comments:
Sep 4 Comments:
/lgtm


Sep 4 Added label: lgtm
Sep 4 Merged pull request