From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 25FDB3AEF29; Thu, 12 Mar 2026 20:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773346296; cv=none; b=IAERgGvPaoUdEhbZ+SLDfEo7ygHrjXclAP63Nq1XNkAhysGmwUHnjsY7Q8ZnaHl6RcrwQZ2ytMHGCEJydiLgwcnqpGIi3Ftyz6CvJyzw84pdmwF3mCVB2emvWTeb3w0Rb9e9I5N44/o2uSxBDGYLnmYuGhnFObSG9RTl71FvbSc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773346296; c=relaxed/simple; bh=g/E4AxlAIFmCbDHDPr0asc74yXi3BaUFmRjiNPlfcQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s1s6e4xXW2PrYP2txQKwZQ4spdfH7cAfnC2PNpZPXZFp1OWNlvSpXdrZMCfugUEFgFi8o/8pha5cV/a6aPXkfZykg1CpPb6UwZ/5ruU+gyOZCUlFtgoCJ+L6BeSATkT4JorNOObZAZduUmVw3WX7EylxKfrGlv54Zeb9i0XOPmo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0NHX/CCx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0NHX/CCx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CE22C4CEF7; Thu, 12 Mar 2026 20:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773346295; bh=g/E4AxlAIFmCbDHDPr0asc74yXi3BaUFmRjiNPlfcQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0NHX/CCxBO0L4RdK1pH5UHF2n4/O3GH5Gfo2zu8gKn51OEbFhkIDm0M50syK95zCQ 87ep/VbXdl6HinAFfgopcUW+1BN7b6kod8Ma54lFd2IcxZxJN+CQYCtzxwU0ostaPk 5MQW5rxJlUap42IXfORUKH655G6d/4MiW59+NxrQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Brad Spengler , Zack Rusin , Ian Forbes , Sasha Levin Subject: [PATCH 6.12 001/265] drm/vmwgfx: Fix invalid kref_put callback in vmw_bo_dirty_release Date: Thu, 12 Mar 2026 21:06:28 +0100 Message-ID: <20260312201018.188395027@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260312201018.128816016@linuxfoundation.org> References: <20260312201018.128816016@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Brad Spengler [ Upstream commit 211ecfaaef186ee5230a77d054cdec7fbfc6724a ] The kref_put() call uses (void *)kvfree as the release callback, which is incorrect. kref_put() expects a function with signature void (*release)(struct kref *), but kvfree has signature void (*)(const void *). Calling through an incompatible function pointer is undefined behavior. The code only worked by accident because ref_count is the first member of vmw_bo_dirty, making the kref pointer equal to the struct pointer. Fix this by adding a proper release callback that uses container_of() to retrieve the containing structure before freeing. Fixes: c1962742ffff ("drm/vmwgfx: Use kref in vmw_bo_dirty") Signed-off-by: Brad Spengler Signed-off-by: Zack Rusin Cc: Ian Forbes Link: https://patch.msgid.link/20260107171236.3573118-1-zack.rusin@broadcom.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c b/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c index de2498749e276..5bb710824d72f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c @@ -274,6 +274,13 @@ int vmw_bo_dirty_add(struct vmw_bo *vbo) return ret; } +static void vmw_bo_dirty_free(struct kref *kref) +{ + struct vmw_bo_dirty *dirty = container_of(kref, struct vmw_bo_dirty, ref_count); + + kvfree(dirty); +} + /** * vmw_bo_dirty_release - Release a dirty-tracking user from a buffer object * @vbo: The buffer object @@ -288,7 +295,7 @@ void vmw_bo_dirty_release(struct vmw_bo *vbo) { struct vmw_bo_dirty *dirty = vbo->dirty; - if (dirty && kref_put(&dirty->ref_count, (void *)kvfree)) + if (dirty && kref_put(&dirty->ref_count, vmw_bo_dirty_free)) vbo->dirty = NULL; } -- 2.51.0