diff options
author | Andrew Goodbody <andrew.goodbody@linaro.org> | 2025-08-07 12:20:01 +0100 |
---|---|---|
committer | Casey Connolly <casey.connolly@linaro.org> | 2025-08-13 15:18:49 +0200 |
commit | be12b6e158a06580437f2e4756eb6021cf0cbfbe (patch) | |
tree | da7891c9be37a6806945392e87bc04f1f4a94c3d | |
parent | 8a0bb0b176069989d645e1edca2737d46770a530 (diff) |
pinctrl: qcom: sa8775: Limit check for array index not correct
In sa8775p_get_pin_name the limit check for the index into
msm_special_pins_data allows for more elements than exist. Add code to
ensure the array index remains in bounds.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Link: https://lore.kernel.org/r/20250807-pinctrl_qcom-v1-1-42fac6707fd5@linaro.org
Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
-rw-r--r-- | drivers/pinctrl/qcom/pinctrl-sa8775p.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pinctrl/qcom/pinctrl-sa8775p.c b/drivers/pinctrl/qcom/pinctrl-sa8775p.c index cb2496ff1fb..d4acae15d55 100644 --- a/drivers/pinctrl/qcom/pinctrl-sa8775p.c +++ b/drivers/pinctrl/qcom/pinctrl-sa8775p.c @@ -516,7 +516,9 @@ static const char *sa8775p_get_function_name(struct udevice *dev, static const char *sa8775p_get_pin_name(struct udevice *dev, unsigned int selector) { - if (selector >= 149 && selector <= 155) + if (selector > 153) + strcpy(pin_name, "unknown"); + else if (selector >= 149) snprintf(pin_name, MAX_PIN_NAME_LEN, msm_special_pins_data[selector - 149].name); else |