From nobody Mon Feb 9 15:09:34 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 814C21F17E8 for ; Sun, 21 Dec 2025 17:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766338493; cv=none; b=VC9on3VAjCrhHhpvzYaocDj0K73KkeFNh4Al5g0Y/AyeEbWt2wg59mWidZRqksdYU7kVmyRO0f0DaWqUMZq0Nzoma3q86DLzyRxC8Aq1iM6IhNRr6k8MiuusxskkNlRKzrKdwS3VayPHNB4/ovt7DC8yRD9ba/YpbYmmFDr6JMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766338493; c=relaxed/simple; bh=WxVX3F5abxiksJPllEOT4QVLa6idYV3QNId0eo1KGnw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TTBdfzg+yrARPziA3xpewuJMw6JyKZX3MpXC6BTrEdFl03JqfZnAa0EvZCBRhBmMiSurvSOx/9XVE0TmqDNRh0KqxZmCQnZR4Rf8KCm/ohy8dG/NLLKxxSBJrMVqdPsd153zkKDzqJtAmOoXGSH75BTiqr6+AKdiQyOqwvqrBfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aHkMHHU7; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aHkMHHU7" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso4617739b3a.1 for ; Sun, 21 Dec 2025 09:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766338492; x=1766943292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2KrzrVgYrqwN2sqBtIPlj1s0XjGGWWfGC3z3Sib6B1A=; b=aHkMHHU7HGAYQQM8QcMmPBrspOhbDcEd9pGRJPwVhdjugPrLetu0M+LToDqmy6HFH2 c4+XjKivPiyQWQ7qv4FfQLPin/OECUKwdDGloBkU2gwEM/YipnMvQQUZDeCysvfcLcYg VDpFhUlmhPYlYT/Ci+b9Y+6cpFnuKv9axU/zKke0aVPghI7yN7lz8+npG5V/fb+/ezC/ uQFiuvXkTHcY0+6wpguRYXHm28R6NVTH2d4b5+8yOmNcG9BnTVofeXAHKvshrT2Nkdcs 7M20cOT3gGLwgYB5NEwHF4sYXSNqDyTsE+jHRxIgK2i49TAiruDoCKZgmTRmeW7dRWNu Ophg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766338492; x=1766943292; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2KrzrVgYrqwN2sqBtIPlj1s0XjGGWWfGC3z3Sib6B1A=; b=OnZJ9YR6/x/pJdfTh4h9gjCYWE3d56QGMzf6GSCsiSjVwKUu5PGh2jqRoVvuvIMdGM +7To0GozAkXXIWtCZsbl9/3lFw6EgLNCkdbQDcIlfGKjQUSGNitLgBX49kfKHszSBl9t jSx1k2rNUyNcDk4GCq8RszYNmuurZ/kI073RPXZXATdfYsIlpPJC5KtQqXXXXzp2JWJu CqcNexFDOG8GSaS8RjL7jAfxdoojx47aKESPYo5VgIUfh/pndjhQuJIGVMM00HjIQYRa NvBdQNQJDg+B8xO+rUi4/r+VpIzg4UnthhiKyn/dCoH4B6Z43N9sWYNEt+/33mSU5sxu PqKA== X-Forwarded-Encrypted: i=1; AJvYcCVj9lgOg9clwpfj7HUSH6NBt5ZL1n2Dm5S5w0gDeBH2mrmieUeluCzBU9kAVlFp2CE/aSzaQTab8Bp4psA=@vger.kernel.org X-Gm-Message-State: AOJu0YyQ1agTTN9S7kGiU9IR7Rk2RUxM7Tsljm05qAXZLBYh96DKIKAu Gm5dw4pu9YmHPS2rHD71peCPapgmfHOGLQDZBTZRGi5qHj+k7FF2m2Kw X-Gm-Gg: AY/fxX42SIgMDHMvaMgsMJopkdOpYQEFNqolqa3zW4/Yms1USBA3674mAgzf4IF5iuM G3zAxgSlVOGWqnoa/RVY9DeKZg8of7lI6SNfhunpjwi5VuUeLQHQldtbz7IFTZ/BMHUBTStSKWE U1Hm0an5KFFmzZ/3Gu1mJicvCA8jN7q8uP1RwiPnfZTyxzn7MYM+PJUVDqwQ3PDHIuupdmq3lQX Y70AudvK3TiilB/nNRom033A45sdNaJGy9afee5ixg9axUzNA+l/cmWZZt9plFczTURaoupwRXP UtvTwVA7U7/qwigBZ5f/SuKeq5QdO6pwRrZsY+M+aXZPpcfOe2xHaiwMeqmSs/lADt95tzm1jsZ c0YLx96JxhD3TsbN3pDqyc4GOSoS4YvN7ykSrRVKIpG/x2Fy5d50c4Ao5sE0SfJv4B2WsXIk4CS ezJxeeL0sErJSPDQgmbA== X-Google-Smtp-Source: AGHT+IEvioj+ZptXQ8FnpuRwwS2JUU+hZ+viSb+CyqVe0Oyil5z+mLKm3cSiCe59x34NbrKhv/SBJQ== X-Received: by 2002:a05:6a00:8c11:b0:7e8:4433:8f9e with SMTP id d2e1a72fcca58-7ff6607e33emr8307839b3a.38.1766338491505; Sun, 21 Dec 2025 09:34:51 -0800 (PST) Received: from rakuram-MSI ([2401:4900:67c6:26a8:e1e1:a093:320f:53b3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7a843a18sm7976174b3a.14.2025.12.21.09.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Dec 2025 09:34:51 -0800 (PST) From: Rakuram Eswaran To: joro@8bytes.org, will@kernel.org, suravee.suthikulpanit@amd.com, robin.murphy@arm.com Cc: dan.carpenter@linaro.org, iommu@lists.linux.dev, lkp@intel.com, linux-kernel@vger.kernel.org, rakuram.e96@gmail.com Subject: [PATCH] iommu: amd: Fix uninitialized dev_data on probe failure Date: Sun, 21 Dec 2025 23:04:16 +0530 Message-ID: <20251221173416.132656-1-rakuram.e96@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" amd_iommu_probe_device() may jump to the out_err path when iommu_init_device() fails. In that case, dev_data has not been initialized yet, but the out_err path unconditionally dereferences dev_data, leading to an uninitialized pointer dereference. The IOMMU core explicitly allows ->probe_device() callbacks to return ERR_PTR() on failure. Return immediately when device initialization fails instead of falling through the shared error path, which assumes that per-device IOMMU state exists. This avoids dereferencing dev_data on error paths where the device was not successfully initialized. Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202512191724.meqJENXe-lkp@intel.com/ Signed-off-by: Rakuram Eswaran --- Testing note: Compile tested only. Build and Analysis: This patch was compiled against the configuration file reported by 0day CI in the above link (config: x86_64-randconfig-r073-20251215) using gcc version 15.2.0 (Ubuntu 15.2.0-4ubuntu4). Static analysis was performed with Smatch to ensure the reported warning no longer reproduces after applying this fix. Command using for testing: ~/project/smatch/smatch_scripts/kchecker ./drivers/iommu/amd/iommu.c drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 5d45795c367a..075125f0f52b 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2426,7 +2426,7 @@ static struct iommu_device *amd_iommu_probe_device(st= ruct device *dev) dev_err(dev, "Failed to initialize - trying to proceed anyway\n"); iommu_dev =3D ERR_PTR(ret); iommu_ignore_device(iommu, dev); - goto out_err; + return iommu_dev; } =20 amd_iommu_set_pci_msi_domain(dev, iommu); --=20 2.51.0