dnotify: Handle errors from fsnotify_add_mark_locked() in fcntl_dirnotify()
authorJan Kara <jack@suse.cz>
Tue, 31 Oct 2017 08:53:28 +0000 (09:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:07:47 +0000 (11:07 +0100)
commit3587188ad596da05a8dd691fc28ee56d335f41b8
tree5bba140e562742d42f56da331c6fbe85c1280089
parent90f9a1ff1e8eaa15c1e33fefa44705707db4de2b
dnotify: Handle errors from fsnotify_add_mark_locked() in fcntl_dirnotify()

commit b3a0066005821acdc0cdb092cb72587182ab583f upstream.

fsnotify_add_mark_locked() can fail but we do not check its return
value. This didn't matter before commit 9dd813c15b2c "fsnotify: Move
mark list head from object into dedicated structure" as none of possible
failures could happen for dnotify but after that commit -ENOMEM can be
returned. Handle this error properly in fcntl_dirnotify() as
otherwise we just hit BUG_ON(dn_mark->dn) in dnotify_free_mark().

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reported-by: syzkaller
Fixes: 9dd813c15b2c101168808d4f5941a29985758973
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/notify/dnotify/dnotify.c