drm: Fixup racy refcounting in plane_force_disable
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 27 Feb 2015 11:58:13 +0000 (12:58 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Thu, 23 Apr 2015 18:58:19 +0000 (14:58 -0400)
commitaa8c34007442353281bb3a6f7372efc2556e3867
tree4aeb45e862231cac24a961c96c9c3320244704c2
parentff06e6e533db84a5cbce79d1b4866e8258b563c9
drm: Fixup racy refcounting in plane_force_disable

[ Upstream commit 8218c3f4df3bb1c637c17552405039a6dd3c1ee1 ]

Originally it was impossible to be dropping the last refcount in this
function since there was always one around still from the idr. But in

commit 83f45fc360c8e16a330474860ebda872d1384c8c
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Wed Aug 6 09:10:18 2014 +0200

    drm: Don't grab an fb reference for the idr

we've switched to weak references, broke that assumption but forgot to
fix it up.

Since we still force-disable planes it's only possible to hit this
when racing multiple rmfb with fbdev restoring or similar evil things.
As long as userspace is nice it's impossible to hit the BUG_ON.

But the BUG_ON would most likely be hit from fbdev code, which usually
invovles the console_lock besides all modeset locks. So very likely
we'd never get the bug reports if this was hit in the wild, hence
better be safe than sorry and backport.

Spotted by Matt Roper while reviewing other patches.

[airlied: pull this back into 4.0 - the oops happens there]

Cc: stable@vger.kernel.org
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/gpu/drm/drm_crtc.c