Commit 94fcae6c authored by Zong Jiang's avatar Zong Jiang Committed by Greg Kroah-Hartman
Browse files

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: 9391ab1e ("serial: qcom-geni: Make UART port count configurable via Kconfig")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202508180815.R2nDyajs-lkp@intel.com/


Signed-off-by: default avatarZong Jiang <quic_zongjian@quicinc.com>
Link: https://lore.kernel.org/r/20250827120319.1682835-1-quic_zongjian@quicinc.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e3fa89f3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment