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