From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DD2F470436; Tue, 21 Jul 2026 17:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656077; cv=none; b=cjAtpJ2T4ZP5mZ8wKL8d5xYE/lM7gnwXlCQcNnm9vsVj2bv5sINobomlAV5txCDViEeiIusyMqNo0wzh7vEelleVBG69ugP5VkEFfYZjeVH5OK6WRph9oCuyqrNITIi+wbQXpQaOOGV154LyUSnfjXmiWg3myB0aLjd7/7IqlPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656077; c=relaxed/simple; bh=32KoGVvkH9aNjYCKAYiWfNJDBCoaLG1aOh+P0cupsXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=awGkLOVISX/T1nKvqJQXgxQtVVeocO+3cpybaRPoChgCc4R45jmHm9z7pgbw2wozGewzjLFz7ZqoL4gzy7/zp2OIiHk1ywv7923vZAvM2iBHAqGuQZryS1kXNvH5GHqLg7MmbN1Wd8SoNwirsK/al6KD1xMHrigQk0+bND8hD/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fB0vzfx/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fB0vzfx/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 791931F000E9; Tue, 21 Jul 2026 17:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784656073; bh=5oiGro4hJ0+F6GnystYH3Visd+5e0B6lFbPP6FAzzgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fB0vzfx/HFgpAEVu8eMU8BcAXCKfes+IBOi0358jRvScp9Rdg8UTUzf22+BcqSnxD gINCqInp07Gn81t8rjbgCje+KzoVai/AmIR3pwfSZkE4aHmjmFrTJ8FaDzdpugd6JD T1UFU23RniBegxxR1aip3GzoQCB5qVdvbZpwHJgU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikko Perttunen , Thierry Reding , Sasha Levin Subject: [PATCH 6.18 0250/1611] gpu: host1x: Fix iommu_map_sgtable() return value check Date: Tue, 21 Jul 2026 17:06:06 +0200 Message-ID: <20260721152520.655933893@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikko Perttunen [ Upstream commit 18f74762013a4b6aa6f905c4459e0f506f9c5c7b ] Commit "iommu: return full error code from iommu_map_sg[_atomic]()" changed iommu_map_sgtable() to return an ssize_t and negative values in error cases, rather than a size_t and a zero. pin_job() also was incorrectly assigning to 'int', which could cause overflows into negative values. Update pin_job() to correctly check for errors from iommu_map_sgtable. Fixes: ad8f36e4b6b1 ("iommu: return full error code from iommu_map_sg[_atomic]()") Signed-off-by: Mikko Perttunen Signed-off-by: Thierry Reding Link: https://patch.msgid.link/20260421-iommu_map_sgtable-return-v1-1-fb484c07d2a1@nvidia.com Signed-off-by: Sasha Levin --- drivers/gpu/host1x/job.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c index 3ed49e1fd93322..70bda32f1ff488 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c @@ -235,6 +235,8 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job) } if (host->domain) { + ssize_t map_err; + for_each_sgtable_sg(map->sgt, sg, j) gather_size += sg->length; @@ -248,11 +250,11 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job) goto put; } - err = iommu_map_sgtable(host->domain, iova_dma_addr(&host->iova, alloc), - map->sgt, IOMMU_READ); - if (err == 0) { + map_err = iommu_map_sgtable(host->domain, iova_dma_addr(&host->iova, alloc), + map->sgt, IOMMU_READ); + if (map_err < 0) { __free_iova(&host->iova, alloc); - err = -EINVAL; + err = map_err; goto put; } -- 2.53.0