Unverified Commit 0d52d06a authored by Christian Brauner's avatar Christian Brauner
Browse files
parent fe67b063
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -1560,24 +1560,16 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
	}
	case SIOCKCMCLONE: {
		struct kcm_clone info;
		struct file *file;

		info.fd = get_unused_fd_flags(0);
		if (unlikely(info.fd < 0))
			return info.fd;
		FD_PREPARE(fdf, 0, kcm_clone(sock));
		if (fdf.err)
			return fdf.err;

		file = kcm_clone(sock);
		if (IS_ERR(file)) {
			put_unused_fd(info.fd);
			return PTR_ERR(file);
		}
		if (copy_to_user((void __user *)arg, &info,
				 sizeof(info))) {
			put_unused_fd(info.fd);
			fput(file);
		info.fd = fd_prepare_fd(fdf);
		if (copy_to_user((void __user *)arg, &info, sizeof(info)))
			return -EFAULT;
		}
		fd_install(info.fd, file);

		fd_publish(fdf);
		err = 0;
		break;
	}