]> www.infradead.org Git - users/dwmw2/linux.git/commit
watch_queue, pipe: Free watchqueue state after clearing pipe ring
authorDavid Howells <dhowells@redhat.com>
Fri, 11 Mar 2022 13:23:38 +0000 (13:23 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Mar 2022 13:16:02 +0000 (14:16 +0100)
commitd729d4e99fb85f734805ff37dd79f38e7db21c0f
tree7a713ecd9928357b1ae8fac0277079488c0edd9b
parent573a3228ca3268441ce334251cb9fec0d69ca574
watch_queue, pipe: Free watchqueue state after clearing pipe ring

commit db8facfc9fafacefe8a835416a6b77c838088f8b upstream.

In free_pipe_info(), free the watchqueue state after clearing the pipe
ring as each pipe ring descriptor has a release function, and in the
case of a notification message, this is watch_queue_pipe_buf_release()
which tries to mark the allocation bitmap that was previously released.

Fix this by moving the put of the pipe's ref on the watch queue to after
the ring has been cleared.  We still need to call watch_queue_clear()
before doing that to make sure that the pipe is disconnected from any
notification sources first.

Fixes: c73be61cede5 ("pipe: Add general notification queue support")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/pipe.c