Thread (8 messages) 8 messages, 4 authors, 2019-05-28

Re: [PATCH v2 1/2] open: add close_range()

From: Christian Brauner <christian@brauner.io>
Date: 2019-05-23 16:34:55
Also in: linux-alpha, linux-api, linux-arch, linux-arm-kernel, linux-fsdevel, linux-kselftest, linux-mips, linux-s390, linux-sh, lkml, sparclinux

On Thu, May 23, 2019 at 06:20:05PM +0200, Oleg Nesterov wrote:
On 05/23, Christian Brauner wrote:
quoted
+int __close_range(struct files_struct *files, unsigned fd, unsigned max_fd)
+{
+	unsigned int cur_max;
+
+	if (fd > max_fd)
+		return -EINVAL;
+
+	rcu_read_lock();
+	cur_max = files_fdtable(files)->max_fds;
+	rcu_read_unlock();
+
+	/* cap to last valid index into fdtable */
+	max_fd = max(max_fd, (cur_max - 1));
                 ^^^

Hmm. min() ?
Yes, thanks! Massive brainf*rt on my end, sorry.

Christian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help