diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> | 2023-05-13 13:35:10 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2023-05-16 15:25:57 +0200 |
commit | 070a10d6fe1b2f4cc5d6c38b478cc059461eabe9 (patch) | |
tree | 1eca59c69c615a432cd9524c117cead6c02799ac /drivers/pinctrl/qcom/pinctrl-sc8180x.c | |
parent | pinctrl: qcom: Refactor generic qcom pinctrl driver (diff) | |
download | linux-070a10d6fe1b2f4cc5d6c38b478cc059461eabe9.tar.xz linux-070a10d6fe1b2f4cc5d6c38b478cc059461eabe9.zip |
pinctrl: qcom: sc8180x: gracefully handle missing IO memory resource
If device was probed with incorrect DT or ACPI tables, the IO memory
resource would be missing and driver would derefernce NULL pointer in
sc8180x_pinctrl_add_tile_resources(). Add simplep check if IO memory
resource was provided to silence Smatch warning:
drivers/pinctrl/qcom/pinctrl-sc8180x.c:1664 sc8180x_pinctrl_add_tile_resources() error: potentially dereferencing uninitialized 'mres'.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230513113510.177666-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/qcom/pinctrl-sc8180x.c')
-rw-r--r-- | drivers/pinctrl/qcom/pinctrl-sc8180x.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/pinctrl/qcom/pinctrl-sc8180x.c b/drivers/pinctrl/qcom/pinctrl-sc8180x.c index f86b176ed0b7..d6a79ad41a40 100644 --- a/drivers/pinctrl/qcom/pinctrl-sc8180x.c +++ b/drivers/pinctrl/qcom/pinctrl-sc8180x.c @@ -1622,7 +1622,8 @@ static const struct msm_pinctrl_soc_data sc8180x_acpi_pinctrl = { static int sc8180x_pinctrl_add_tile_resources(struct platform_device *pdev) { int nres_num = pdev->num_resources + ARRAY_SIZE(sc8180x_tiles) - 1; - struct resource *mres, *nres, *res; + struct resource *mres = NULL; + struct resource *nres, *res; int i, ret; /* @@ -1649,6 +1650,9 @@ static int sc8180x_pinctrl_add_tile_resources(struct platform_device *pdev) *res++ = *r; } + if (!mres) + return -EINVAL; + /* Append tile memory resources */ for (i = 0; i < ARRAY_SIZE(sc8180x_tiles); i++, res++) { const struct tile_info *info = &sc8180x_tile_info[i]; |