Yuntao Wang 229bce543b fs/file: fix the check in find_next_fd()
[ Upstream commit ed8c7fbdfe117abbef81f65428ba263118ef298a ]

The maximum possible return value of find_next_zero_bit(fdt->full_fds_bits,
maxbit, bitbit) is maxbit. This return value, multiplied by BITS_PER_LONG,
gives the value of bitbit, which can never be greater than maxfd, it can
only be equal to maxfd at most, so the following check 'if (bitbit > maxfd)'
will never be true.

Moreover, when bitbit equals maxfd, it indicates that there are no unused
fds, and the function can directly return.

Fix this check.

Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
Link: https://lore.kernel.org/r/20240529160656.209352-1-yuntao.wang@linux.dev
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-27 10:40:18 +02:00
..
2021-09-18 13:40:15 +02:00
2024-04-13 12:58:19 +02:00
2024-02-23 08:42:14 +01:00
2024-03-01 13:16:43 +01:00
2023-09-23 11:01:09 +02:00
2024-06-21 14:52:47 +02:00
2022-06-09 10:21:16 +02:00
2024-06-21 14:52:47 +02:00
2023-12-08 08:46:15 +01:00
2024-06-21 14:53:37 +02:00
2023-01-04 11:39:23 +01:00
2024-06-21 14:52:59 +02:00
2024-07-05 09:12:55 +02:00
2023-01-14 10:16:27 +01:00