UPSTREAM: drm/atomic: Handle -EDEADLK with out-fences correctly

commit 7f5d6dac548b983702dd7aac1d463bd88dff50a8 upstream.

complete_crtc_signaling is freeing fence_state, but when retrying
num_fences and fence_state are not zero'd. This caused duplicate
fd's in the fence_state array, followed by a BUG_ON in fs/file.c
because we reallocate freed memory, and installing over an existing
fd, or potential other fun.

Zero fence_state and num_fences correctly in the retry loop, which
allows kms_atomic_transition to pass.

Fixes: beaf5af48034 ("drm/fence: add out-fences support")
Cc: Gustavo Padovan <>
Cc: Brian Starkey <> (v10)
Cc: Sean Paul <>
Cc: Daniel Vetter <>
Cc: Jani Nikula <>
Cc: David Airlie <>
Signed-off-by: Maarten Lankhorst <>
Cc: <> # v4.10+
Testcase: kms_atomic_transitions.plane-all-modeset-transition-fencing
Reviewed-by: Daniel Vetter <> #intel-gfx on irc

Change-Id: I2cfcc8c4d808061a947b2dc977705e738e48b9e8
Fixes: Change-Id: I5fed59f7358aaf3f3acd7a4ca9c85091f23cdbf5
       ("BACKPORT: drm/fence: add out-fences support")
Signed-off-by: Amit Pundir <>
1 file changed