Yuntao Wang 2ffe891b8d 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:46:09 +02:00
..
2024-04-10 16:18:38 +02:00
2024-02-23 08:54:51 +01:00
2021-12-29 12:28:59 +01:00
2024-03-01 13:21:43 +01:00
2023-09-23 11:10:01 +02:00
2023-12-08 08:48:04 +01:00
2023-08-30 16:18:19 +02:00
2024-04-10 16:19:01 +02:00
2022-12-14 11:37:31 +01:00
2024-07-05 09:14:50 +02:00
2023-01-12 11:58:47 +01:00
2022-07-02 16:41:17 +02:00
2022-07-12 16:35:08 +02:00
2021-12-14 10:57:15 +01:00