From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9686EE81BB1 for ; Mon, 9 Feb 2026 13:14:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B12210E3EA; Mon, 9 Feb 2026 13:14:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YXAloL0e"; dkim-atps=neutral Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id E22DF10E3E8 for ; Mon, 9 Feb 2026 13:14:35 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id 38308e7fff4ca-382f0732612so16409911fa.1 for ; Mon, 09 Feb 2026 05:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770642874; x=1771247674; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RoPSheucwNdJ0J9aHupvUSWIaFIaKnYUl6Un356KuXI=; b=YXAloL0e55NU2DhaxWXcqZgjhgZb4uuNMuB5PG6Cv+ZPKdA+BU7T3QcylwSizEPugV 2yI5HqsfAJzqB4z9POBkG5Wf/pSkZ3czPfAeb7+nUHpVXhGr99GsVhFsuni66xvPZp1X 7/uGTmz810CcB9Fnw28Gl7/WGTKbpvKC+j2Q4sU5nuJCdVc7WJOIssglo45UwiY2FO01 oAZwGuxRKwVo3SDeZXzbRM7iVjJNFFhJr9NxkK+rO7ajRvQF4WRUHbGG7z1ncEJ4eHFi TEW9Sdi5WwH6ContFZqJF7w7h42r0KSABtoJpM4eX/NPdg2/GYA606/PRf3UffQ1cFbL HVIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770642874; x=1771247674; 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=RoPSheucwNdJ0J9aHupvUSWIaFIaKnYUl6Un356KuXI=; b=DvvZrNdByoBNywe4AIkLdFAwLFrAg5ZxaYYKk+JkH/uC7ySFAW7usb2NVWNI/r88ik Dun5Ivk2XTcMumH/yosknDkOHXl8wGmAUanGfW1vgP6kOHPwmeIfjvKmfF1ZZwp4xRAE 7y8SsptAzJqPKc1ursmdBW7cMwdxFz9yX54Zd52qVoH9Nr7hCMT4vO4GOF2YqrwCi9pF y8EmXRzCFlDrzCe+ga8MnPX8lVeHWPAMVjUrebinMTmVoY+bcJOOKqSUrXScBYsQV8pv vG8s2WlwEsdrttHe1FC6RgxyA9c/sLL2g+CBsRxunbarM9aha9DHcc0Jo1rg1MUu1ltz uDjQ== X-Forwarded-Encrypted: i=1; AJvYcCXp3CdYtQ3qgnara1LztwoZZCYAKDfhBC8u1JQ2ti+iTVuEGZwkmaJOqayXcRsV75hBo7lZCtjgW+Y=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxUfG7QChBvn5fYm8d3DS/hhgDKCD9hk1iQIBy1OouaTNiFhs5W dM2jlkitstlMKb3A9VmzdSFGhluiGSDezWCpE2+GgJJ/s6Gt6ACWqFR9 X-Gm-Gg: AZuq6aIKTNLZMwKuQ+I83KmxH+Gy4jhE11WZolewTQdeyRyuhY4VFqsUwQukUYZ4Spp EvWfCyu+iBHqsZ5Inqh0YCoNPX+kSDOolaBRSJ+koyDqd4JBnX8WslO4GrvSisjZUOa6Zik7Mvz +UeRQG1BypQOd9W4XdDojEWQE+VWh948l8wp8qcYjBWxhGVA9q2lgK4cwWvsKcIC5tGb+9m1OMy NTaIGQaHH/oA72iUgK2s/t4hRQj42t23m3VCmqzn3ifZ6Tx51ddwBv0XkJQ0ag8xisVd8JkhJMx tpPbUhNi3FNj4ku7bgHvQLgw6FnD7ecgh8dRJizfGCdKAwexmd3pjEv5xr0D8wuxZBl+8N/MYrH 0xepb/skbIJkBGAVkmoniF4yvGAtMVtjysABfK/Iweu5ZS6zGXN6YTrAFGKB8iPK2zw6rxFP3HB 38wfnCihVfqSOkkybzelujDdFhT4VeUwT1Oug/tt7SHc99sImAAyLIHDFboKxAxuUBGAe21tQIA IE+LpKfqw8+81s= X-Received: by 2002:a05:651c:b22:b0:386:1ce2:1198 with SMTP id 38308e7fff4ca-386b5110ee8mr29967281fa.31.1770642873785; Mon, 09 Feb 2026 05:14:33 -0800 (PST) Received: from localhost.localdomain ([176.33.64.73]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-386b63e8483sm27212191fa.34.2026.02.09.05.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Feb 2026 05:14:33 -0800 (PST) From: Alper Ak To: Thierry Reding Cc: Mikko Perttunen , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Alper Ak Subject: [PATCH] gpu: host1x: Fix passing zero to ERR_PTR in host1x_iommu_attach() Date: Mon, 9 Feb 2026 16:14:26 +0300 Message-ID: <20260209131426.37611-1-alperyasinak1@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When iommu_attach_group() returns -ENODEV, the code sets err to 0 but still falls through to the error path, returning ERR_PTR(0). Returning ERR_PTR(0) evaluates to NULL and breaks the ERR_PTR/IS_ERR contract, causing the error to be silently ignored and potentially leading to NULL pointer dereferences by callers. Fix this by returning NULL when err is zero, and ERR_PTR(err) only for actual error codes. This issue was reported by the Smatch static analyzer. Fixes: 06867a362de0 ("gpu: host1x: Set DMA mask based on IOMMU setup") Signed-off-by: Alper Ak --- drivers/gpu/host1x/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 3f475f0e6545..46a570b861ac 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -450,7 +450,7 @@ static struct iommu_domain *host1x_iommu_attach(struct host1x *host) iommu_group_put(host->group); host->group = NULL; - return ERR_PTR(err); + return err ? ERR_PTR(err) : NULL; } static int host1x_iommu_init(struct host1x *host) -- 2.43.0