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 D683E448CF4; Thu, 30 Jul 2026 15:28:47 +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=1785425328; cv=none; b=VJqW+6TWTzvedKH2wEZYGxID20LVAWZzYbrsYu/rOAo3byKTZorSfRikBMyYjcD2yVBPUcZVCcEOer8Dh2RzN1rI5bSS0ZcWOG3wdW/0G3550OrAi5udLWODeK0GEnK0xWFcf7hLIEna4syzsZCnP6HRF3Msde7FT8WnH1qZgkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785425328; c=relaxed/simple; bh=4QET7/hTA07HYfbTmn+GABUN8GcyDoMYyKN7wxeQgus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rrsKHF6m7uPirIY/MNW2fswNpY83+cTos/XNYLQlSMa2zGue5UfRyglIk5JhsTFeXYli8QNE8tPMDCK8n2tIxRs3+LEXO+cCcVzBruqLXuIEc/+bdbaIyMtESfCEkPjLeNBalX9n7ZxZJBKM4r7mOs9NqYxI7YGL45YMoc0NvbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=af+SAJKO; 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="af+SAJKO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF6AC1F000E9; Thu, 30 Jul 2026 15:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785425327; bh=AjmaBbJELSbmCba5KYEJRLI2XJTr8nb7JharMstOo7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=af+SAJKO3x3T9qyClsCIAF9VQ8emlKsmcUA804ZwN5dK8usHZ0WNN3yRGIJbJv4pN BLuOaOg9RMhVWQNJWi72LOhDMphBEyRa9CgOeKiQJK71aqTfKRpCVnalqmGk6PerVP OmTT9UMVFkf5B5Mgjt3OVfxIBgpV/emvfhYoZTZI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Mikko Perttunen , Thierry Reding , Sasha Levin Subject: [PATCH 6.12 030/602] gpu: host1x: Fix use-after-free in host1x_bo_clear_cached_mappings Date: Thu, 30 Jul 2026 16:07:02 +0200 Message-ID: <20260730141436.640637940@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141435.976815864@linuxfoundation.org> References: <20260730141435.976815864@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikko Perttunen [ Upstream commit 266cddf7bd0f6c79b6c0633aef742a22bf70265b ] __host1x_bo_unpin() drops the last reference to the mapping and frees it, so we can't dereference mapping afterwards. The cache itself outlives the mapping, so use the cache local variable instead. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/linux-tegra/ah6ErK6f4kVudVIA@stanley.mountain/T/#u Signed-off-by: Mikko Perttunen Signed-off-by: Thierry Reding Link: https://patch.msgid.link/20260603-host1x-bocache-leak-fix-v1-1-494101dbfd30@nvidia.com Signed-off-by: Sasha Levin --- drivers/gpu/host1x/bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index ef42e9a883f4f9..4dd83627fae06a 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -1006,10 +1006,10 @@ void host1x_bo_clear_cached_mappings(struct host1x_bo *bo) if (WARN_ON(!cache)) continue; - mutex_lock(&mapping->cache->lock); + mutex_lock(&cache->lock); WARN_ON(kref_read(&mapping->ref) != 1); __host1x_bo_unpin(&mapping->ref); - mutex_unlock(&mapping->cache->lock); + mutex_unlock(&cache->lock); } } EXPORT_SYMBOL(host1x_bo_clear_cached_mappings); -- 2.53.0