[PATCH] drm/mediatek: Fix refcounting in mtk_drm_get_all_drm_priv
Johan Hovold
johan at kernel.org
Mon Oct 6 02:49:47 PDT 2025
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 at 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
More information about the Linux-mediatek
mailing list