lkml.org 
[lkml]   [2022]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 4/4] file: Fix file descriptor leak in copy_fd_bitmaps()
On Tue, Mar 29, 2022 at 11:21 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> Yep, that works:

Ok, I'll apply that asap.

I think the "do this better" version is to get rid of
count_open_files() and moving all the logic into sane_fdtable_size(),
and you end up with something like this:

static unsigned int sane_fdtable_size(struct fdtable *fdt,
unsigned int max_fds)
{
unsigned int i;

max_fds = min(max_fds, fdt->max_fds);
i = (max_fds + BITS_PER_LONG - 1) / BITS_PER_LONG;
while (i > 0) {
if (fdt->open_fds[--i])
break;
}
return (i + 1) * BITS_PER_LONG;
}

but considering that I couldn't even get the simple ALIGN() in the
right place, I think going with the obvious version I should have
picked originally is the way to go..

Linus

\
 
 \ /
  Last update: 2022-03-30 08:31    [W:0.333 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site