Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Protopopov <a.s.protopopov@gmail.com>
To: Sven Peter <sven@kernel.org>, Joerg Roedel <joro@8bytes.org>,
	Will Deacon <will@kernel.org>, Janne Grunau <j@jannau.net>,
	Neal Gompa <neal@gompa.dev>, Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux.dev, asahi@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org
Cc: Anton Protopopov <a.s.protopopov@gmail.com>
Subject: [PATCH] iommu/apple-dart: Properly check the error
Date: Fri, 27 Nov 2026 09:51:18 +0000	[thread overview]
Message-ID: <20261127095119.1342988-1-a.s.protopopov@gmail.com> (raw)

The apple_dart_device_group() function expects pci_device_group()
(or generic_device_group() for a non-PCI device) to return NULL on
failure. However, both of them return an error pointer instead of
NULL. The error pointer then is immediately dereferenced by the
iommu_group_get_iommudata() function.

Check for an error pointer instead of NULL and return the error.

Fixes: f0b636804c7c ("iommu/dart: Clear sid2group entry when a group is freed")
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
---

(Found accidentally, while working on BPF stuff.)

 drivers/iommu/apple-dart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index d8302128b465..36ce5ac39b7b 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -981,8 +981,8 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)
 #endif
 		group = generic_device_group(dev);
 
-	res = ERR_PTR(-ENOMEM);
-	if (!group)
+	res = group;
+	if (IS_ERR(group))
 		goto out;
 
 	group_master_cfg = iommu_group_get_iommudata(group);


             reply	other threads:[~2026-11-27  9:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  9:51 Anton Protopopov [this message]
2026-11-30 10:04 ` [PATCH] iommu/apple-dart: Properly check the error Joerg Roedel

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=20261127095119.1342988-1-a.s.protopopov@gmail.com \
    --to=a.s.protopopov@gmail.com \
    --cc=asahi@lists.linux.dev \
    --cc=iommu@lists.linux.dev \
    --cc=j@jannau.net \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=neal@gompa.dev \
    --cc=robin.murphy@arm.com \
    --cc=sven@kernel.org \
    --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