Re: [PATCH] iommu/amd: Fix undefined behavior in devid_write debugfs function

Will Deacon <[email protected]>
Newsgroups dev.linux.lists.iommu,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, 01 Jun 2026 08:12:40 -0400, lirongqing wrote:
> When for_each_pci_segment() loop completes without finding a matching
> segment, the pci_seg pointer is not NULL but points to an invalid memory
> location (the list head). Accessing pci_seg->id after the loop causes
> undefined behavior.
> 
> Fix this by handling the successful case inside the loop and returning
> -EINVAL after the loop if no matching segment is found.
> 
> [...]

Applied to iommu (amd/amd-vi), thanks!

[1/1] iommu/amd: Fix undefined behavior in devid_write debugfs function
      https://git.kernel.org/iommu/c/843e14998966

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.