The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: Hemanth Selam <hemanth.selam@gmail.com>, joro@8bytes.org
Cc: suravee.suthikulpanit@amd.com, will@kernel.org,
	robin.murphy@arm.com, jgg@nvidia.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/amd: Fix ineffective error check in nested domain allocation
Date: Tue, 25 Aug 2026 16:44:46 +0530	[thread overview]
Message-ID: <c20208dd-b3e7-4fe4-a1cf-1d671d3985d7@amd.com> (raw)
In-Reply-To: <20260825100554.2787577-1-hemanth.selam@gmail.com>



On 8/25/2026 3:35 PM, Hemanth Selam wrote:
> 
> amd_iommu_pdom_id_alloc() returns an int: a domain ID on success, or the
> negative errno from ida_alloc_range() when the ID space is exhausted or
> memory is short.  amd_iommu_alloc_domain_nested() stores that return value
> in gdom_info->hdom_id, which is a u32, and only then tests it:
> 
>         gdom_info->hdom_id = amd_iommu_pdom_id_alloc();
>         if (gdom_info->hdom_id <= 0) {
> 
> The assignment discards the sign, so -ENOSPC becomes 0xffffffe4 and the
> test never fires.  The nested domain is then set up with a host domain ID
> that was never allocated, instead of the allocation failing with -ENOSPC.
> 
> Keep the value in an int, test it there, and store it only once it is
> known to be valid, which is what the other amd_iommu_pdom_id_alloc()
> callers already do.
> 
> Fixes: 757d2b1fdf5b ("iommu/amd: Introduce gDomID-to-hDomID Mapping and handle parent domain invalidation")
> Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com>

Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>

-Vasant


      reply	other threads:[~2026-08-25 11:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 10:05 [PATCH] iommu/amd: Fix ineffective error check in nested domain allocation Hemanth Selam
2026-08-25 11:14 ` Vasant Hegde [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c20208dd-b3e7-4fe4-a1cf-1d671d3985d7@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=hemanth.selam@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox