pinctrl: qcom: Address two Smatch reported issues
Subsystems (4)
cover pinctrl: qcom: Address two Smatch reported issues
Smatch reported issues with the limit checks in these two drivers that could lead to an index in an array going out of bounds.
---
Andrew Goodbody (2):
pinctrl: qcom: sa8775: Limit check for array index not correct
pinctrl: qcom: sdm845: Limit check off by 1
drivers/pinctrl/qcom/pinctrl-sa8775p.c | 4 +++- drivers/pinctrl/qcom/pinctrl-sdm845.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
---
base-commit: 3526f990b77fca1c933f1d8b24eb9385010a05bf
change-id: 20250807-pinctrl_qcom-5aa7ec35301b
Best regards,
Signature · 1 line
Andrew Goodbody <[email protected]>
PATCH 1/2 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.
--- drivers/pinctrl/qcom/pinctrl-sa8775p.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-sa8775p.c +3 -1
@@ -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
Signature · 1 line
2.39.5
PATCH 2/2 pinctrl: qcom: sdm845: Limit check off by 1
In reply to Andrew GoodbodyThe driver specifies 154 pins so should have a maximum selector of 153 to ensure that the index into the array special_pins_names does not overflow.
This issue was found by Smatch.
--- drivers/pinctrl/qcom/pinctrl-sdm845.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-sdm845.c +1 -1
@@ -72,7 +72,7 @@ static const char *sdm845_get_pin_name(struct udevice *dev, "sdc2_data", }; -if (selector >=150 && selector <=154 ) +if (selector >=150 && selector <=153 )snprintf (pin_name,MAX_PIN_NAME_LEN , special_pins_names[selector -150 ]);else snprintf (pin_name,MAX_PIN_NAME_LEN ,"gpio%u" , selector);
Signature · 1 line
2.39.5
Quoted 4 lines · Andrew Goodbody
Smatch reported issues with the limit checks in these two drivers that could lead to an index in an array going out of bounds.
Signed-off-by Andrew Goodbody <[email protected]>
Quoted 13 lines
---
Andrew Goodbody (2):
pinctrl: qcom: sa8775: Limit check for array index not correct
pinctrl: qcom: sdm845: Limit check off by 1drivers/pinctrl/qcom/pinctrl-sa8775p.c | 4 +++- drivers/pinctrl/qcom/pinctrl-sdm845.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)---
base-commit:3526f990b77fca1c933f1d8b24eb9385010a05bf
change-id: 20250807-pinctrl_qcom-5aa7ec35301bBest regards,
Signature · 1 line
// Casey (she/her)
Casey Connolly
AppliedQuoted 4 lines · Andrew Goodbody
Smatch reported issues with the limit checks in these two drivers that could lead to an index in an array going out of bounds.
Applied, thanks!
[1/2] pinctrl: qcom: sa8775: Limit check for array index not correct
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/be12b6e158a0
[2/2] pinctrl: qcom: sdm845: Limit check off by 1
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/d9fbc1d70bc9
Best regards,
Signature · 1 line
// Caleb (they/them)