--- x/fs/fuse/dev.c +++ d/fs/fuse/dev.c @@ -1864,15 +1864,6 @@ static ssize_t fuse_dev_do_write(struct if (oh.len != nbytes) goto copy_finish; - /* - * Zero oh.unique indicates unsolicited notification message - * and error contains notification code. - */ - if (!oh.unique) { - err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); - goto out; - } - err = -EINVAL; if (oh.error <= -512 || oh.error > 0) goto copy_finish; @@ -1933,6 +1924,13 @@ static ssize_t fuse_dev_do_write(struct fuse_request_end(req); out: + /* + * Zero oh.unique indicates unsolicited notification message + * and error contains notification code. + */ + if (!oh.unique) + err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); + return err ? err : nbytes; copy_finish: