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
chaizhengtongAdd on Sep 2
chaizhengtong
chaizhengtongCollaborators
Sep 2
增加emulation中AllocDev 的空指针校验
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for chaizhengtong's contribution.)
chaizhengtongchaizhengtongCollaborators
Sep 2 Created pull request, commit 7911aaab
atomgit-bot
atomgit-bot
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),由调用方处理分配失败,不再触发对空指针的写入。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 2 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 2 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
65 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 4 Added label: approved
chaizhengtongchaizhengtongCollaborators
Sep 4 Resolved final issue
gaoxingwang
gaoxingwangCollaborators
Sep 4 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 4 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 4 Merged pull request