In fanotify_encode_fh(), both cases of NULL inode and failure to encode ended up with fh type FILEID_INVALID. Distiguish the case of NULL inode, by setting fh type to FILEID_ROOT. This is needed because fanotify_fh_equal() treats FILEID_INVALID specially and we are going to need fanotify_fh_equal() to return true when comparing two null fids. Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> --- fs/notify/fanotify/fanotify.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 1e4a345155dd..bdafc76cc258 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -282,8 +282,11 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, void *buf = fh->buf; int err; + /* FAN_DIR_MODIFY does not encode object fh */ + fh->type = FILEID_ROOT; + fh->len = 0; if (!inode) - goto out; + return; dwords = 0; err = -ENOENT; @@ -318,7 +321,6 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, type, bytes, err); kfree(ext_buf); *fanotify_fh_ext_buf_ptr(fh) = NULL; -out: /* Report the event without a file identifier on encode error */ fh->type = FILEID_INVALID; fh->len = 0; -- 2.17.1