diff --git a/fs/namespace.c b/fs/namespace.c index 4494064205a6..1390e9e521d6 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -5138,6 +5138,8 @@ SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req, scoped_guard(rwsem_read, &namespace_sem) ret = do_listmount(kreq.mnt_id, kreq.param, kmnt_ids, nr_mnt_ids); + if (ret <= 0) + return ret; if (copy_to_user(mnt_ids, kmnt_ids, ret * sizeof(*mnt_ids))) return -EFAULT;