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 8BECFCAC5B8 for ; Mon, 6 Oct 2025 09:49:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE92D10E347; Mon, 6 Oct 2025 09:49:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="r8NcdP3t"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8F30C10E347 for ; Mon, 6 Oct 2025 09:49:49 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 6943C40A5C; Mon, 6 Oct 2025 09:49:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 409EBC4CEF5; Mon, 6 Oct 2025 09:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759744189; bh=bQYO0VYtBtio80MmlSTfZwF05jmL0sNFgnqPZjKtqzo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r8NcdP3tmUHEJD/5oHfudOZ3+YWlX59Fzq+n2oTdWwrvPdSOEOpBO04z+2qMleb2t mTSxMK6cFadRiZbhMGuRNRCanftfMrGqUS1EIO1lLxiDAFrzwCwHDxNA6EQqxHFk2H u03XXCBG9JKSAG1S3iGxX+OTGY0jH/qcmQWU2Pow13z0tm/lyQWDe1Rh7gs9YNbZfD x3R387n+1EwQwBU7OwpJQd0iQkaIjOplQsG0Rfd9D6cvKhFQopXDu6mdCCjju3+VAz 3qKpA/bwvjD7QpTj7cjlEK7lHHT4+IezQzZTzKDkFRq8QwDqAvHsJtP4a2wCxyhSWa 8kr+wc2WDemIw== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1v5hql-000000007Oc-0j5U; Mon, 06 Oct 2025 11:49:47 +0200 Date: Mon, 6 Oct 2025 11:49:47 +0200 From: Johan Hovold To: Sjoerd Simons Cc: Chun-Kuang Hu , Philipp Zabel , David Airlie , Simona Vetter , Matthias Brugger , AngeloGioacchino Del Regno , CK Hu , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, stable@vger.kernel.org Subject: Re: [PATCH] drm/mediatek: Fix refcounting in mtk_drm_get_all_drm_priv Message-ID: References: <20251003-mtk-drm-refcount-v1-1-3b3f2813b0db@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251003-mtk-drm-refcount-v1-1-3b3f2813b0db@collabora.com> 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" On Fri, Oct 03, 2025 at 10:08:28AM +0200, Sjoerd Simons wrote: > dev_get_drvdata simply returns the driver data part of drm_dev, which > has its lifetime bound to the drm_dev. No, that is not correct: the driver data goes away when the driver is unbound, not when the device is freed. > So only drop the reference in the > error paths, on success they will get dropped later. But there is indeed a partial fix for the device leak here which was overlooked. Good catch. > Cc: stable@vger.kernel.org > Fixes: 9ba2556cef1df ("drm/mediatek: clean up driver data initialisation") This is clearly not the commit that introduced the issue (even if I also failed to notice the reference imbalance). Since there is no need to keep the references, I've just sent a fix which instead fixes this by dropping the previous partial fix: https://lore.kernel.org/r/20251006093937.27869-1-johan@kernel.org Johan