diff options
author | Zong Jiang <quic_zongjian@quicinc.com> | 2025-08-27 20:03:19 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-09-06 15:48:43 +0200 |
commit | 94fcae6cb1c1dec20a5bd0e324b23057fa4eae09 (patch) | |
tree | 01f9705bf61c99f235052de1a15983efcc1306e3 /rust/helpers/helpers.c | |
parent | e3fa89f3a768a9c61cf1bfe86b939ab5f36a9744 (diff) |
serial: qcom-geni: Fix off-by-one error in ida_alloc_range()
The ida_alloc_range() function expects an inclusive range, meaning both
the start and end values are valid allocation targets. Passing nr_ports
as the upper bound allows allocation of an ID equal to nr_ports, which
is out of bounds when used as an index into the port array.
Fix this by subtracting 1 from nr_ports in both calls to ida_alloc_range(),
ensuring the allocated ID stays within the valid range
[start, nr_ports - 1].
This prevents potential out-of-bounds access when the allocated ID is used
as an index.
Fixes: 9391ab1ed9b3 ("serial: qcom-geni: Make UART port count configurable via Kconfig")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202508180815.R2nDyajs-lkp@intel.com/
Signed-off-by: Zong Jiang <quic_zongjian@quicinc.com>
Link: https://lore.kernel.org/r/20250827120319.1682835-1-quic_zongjian@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/helpers/helpers.c')
0 files changed, 0 insertions, 0 deletions