Skip to contentSkip to conversation

regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure

PATCH In review Krzysztof Kozlowski 3 participants 6 messages Jun 19, 2019 – Jun 24, 2019 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Krzysztof Kozlowski

author maintainer
#0 lore raw

PATCH 1/1 regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure

If devm_gpiod_get_from_of_node() call returns ERR_PTR, it is assigned into an array of GPIO descriptors and used later because such error is not treated as critical thus it is not propagated back to the probe function.

All code later expects that such GPIO descriptor is either a NULL or proper value. This later might lead to dereference of ERR_PTR.

Only devices with S2MPS14 flavor are affected (other do not control regulators with GPIOs).

Fixes 1c984942f0a4 ("regulator: s2mps11: Pass descriptor instead of GPIO number")

---

The exact error condition was not tested because I do not have board with S2MPS14.

---
 drivers/regulator/s2mps11.c | 1 +
 1 file changed, 1 insertion(+)
drivers/regulator/s2mps11.c +1 -0
index 134c62db36c5..af9bf10b4c33 100644
@@ -824,6 +824,7 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 		if (IS_ERR(gpio[reg])) {
 			dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n",
 				reg, rdata[reg].name);
+			gpio[reg] = NULL;
 			continue;
 		}
 		if (gpio[reg])
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Applied "regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure" to the regulator tree

The patch

regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure

has been applied to the regulator tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.2

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 70ca117b02f3b1c8830fe95e4e3dea2937038e11 Mon Sep 17 00:00:00 2001

From: Krzysztof Kozlowski <[email protected]>
Date: Wed, 19 Jun 2019 14:42:39 +0200
Subject: [PATCH] regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup
failure

If devm_gpiod_get_from_of_node() call returns ERR_PTR, it is assigned into an array of GPIO descriptors and used later because such error is not treated as critical thus it is not propagated back to the probe function.

All code later expects that such GPIO descriptor is either a NULL or proper value. This later might lead to dereference of ERR_PTR.

Only devices with S2MPS14 flavor are affected (other do not control regulators with GPIOs).

Fixes 1c984942f0a4 ("regulator: s2mps11: Pass descriptor instead of GPIO number")
---
 drivers/regulator/s2mps11.c | 1 +
 1 file changed, 1 insertion(+)
drivers/regulator/s2mps11.c +1 -0
index 134c62db36c5..af9bf10b4c33 100644
@@ -824,6 +824,7 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 		if (IS_ERR(gpio[reg])) {
 			dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n",
 				reg, rdata[reg].name);
+			gpio[reg] = NULL;
 			continue;
 		}
 		if (gpio[reg])
Signature · 1 line
2.20.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

author maintainer
#3 lore raw
Quoted 8 lines · Sasha Levin

Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number.

Quoted 8 lines

The bot has tested the following trees: v5.1.12, v4.19.53.

v5.1.12: Build OK!
v4.19.53: Failed to apply! Possible dependencies:
Unable to calculate

How should we proceed with this patch?

The commit mentioned in fixes tag (1c984942f0a4) came in v5.0-rc1/v5.0. Why do you try to port it to v4.19?

Best regards,
Krzysztof

maintainer
#4 lore raw
Quoted 16 lines · Krzysztof Kozlowski
Quoted 15 lines · Sasha Levin

Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number.

The bot has tested the following trees: v5.1.12, v4.19.53.

v5.1.12: Build OK!
v4.19.53: Failed to apply! Possible dependencies:
Unable to calculate

Quoted 4 lines
Quoted 1 line

How should we proceed with this patch?

The commit mentioned in fixes tag (1c984942f0a4) came in v5.0-rc1/v5.0. Why do you try to port it to v4.19?

This is an interesting one! Usually when something like this happens, it means that the "fixed" commit was backported to stable, but as you pointed out, it was not.

My scripts have logic to try and detect these backports, and it appears that there's a commit with an identical subject line in the 4.19 tree, so at this point there are two commits with identical subject lines in Linus's tree:

1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number 0369e02b75e6 regulator: s2mps11: Pass descriptor instead of GPIO number

Which can be confusing for humans too :)

--
Thanks,
Sasha

author maintainer
#5 lore raw
Quoted 32 lines · Sasha Levin
Quoted 16 lines · Krzysztof Kozlowski
Quoted 15 lines · Sasha Levin

Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number.

The bot has tested the following trees: v5.1.12, v4.19.53.

v5.1.12: Build OK!
v4.19.53: Failed to apply! Possible dependencies:
Unable to calculate

Quoted 4 lines
Quoted 1 line

How should we proceed with this patch?

The commit mentioned in fixes tag (1c984942f0a4) came in v5.0-rc1/v5.0. Why do you try to port it to v4.19?

This is an interesting one! Usually when something like this happens, it means that the "fixed" commit was backported to stable, but as you pointed out, it was not.

My scripts have logic to try and detect these backports, and it appears that there's a commit with an identical subject line in the 4.19 tree, so at this point there are two commits with identical subject lines in Linus's tree:

Quoted 4 lines

1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number 0369e02b75e6 regulator: s2mps11: Pass descriptor instead of GPIO number

Which can be confusing for humans too :)

+CC Mark Brown,

Ugh, I see more of commits from this patchset getting to mainline twice. One branch goes to Linus via 79f20778fb228ae372cd7602745382fd4543ef31 Merge tag 'regulator-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
which is based on v4.20-rc1

The other commits gets there via:
68cc38ff33f38424d0456f9a1ecfec4683226a7e Merge tag 'regulator-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
which is before (gets into v4.18-rc1).

But how the latter can be applied again if it is based on something already containing these commits... I am so confused...

Anyway the Fixes needs to be corrected to contain both (also 0369e02b75e6) and should be backported to v4.19... I'll see if I have spare time to make a backport.

Best regards,
Krzysztof

author maintainer
#6 lore raw
Quoted 52 lines · Krzysztof Kozlowski
Quoted 32 lines · Sasha Levin
Quoted 16 lines · Krzysztof Kozlowski
Quoted 15 lines · Sasha Levin

Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number.

The bot has tested the following trees: v5.1.12, v4.19.53.

v5.1.12: Build OK!
v4.19.53: Failed to apply! Possible dependencies:
Unable to calculate

Quoted 4 lines
Quoted 1 line

How should we proceed with this patch?

The commit mentioned in fixes tag (1c984942f0a4) came in v5.0-rc1/v5.0. Why do you try to port it to v4.19?

This is an interesting one! Usually when something like this happens, it means that the "fixed" commit was backported to stable, but as you pointed out, it was not.

My scripts have logic to try and detect these backports, and it appears that there's a commit with an identical subject line in the 4.19 tree, so at this point there are two commits with identical subject lines in Linus's tree:

Quoted 4 lines

1c984942f0a4 regulator: s2mps11: Pass descriptor instead of GPIO number 0369e02b75e6 regulator: s2mps11: Pass descriptor instead of GPIO number

Which can be confusing for humans too :)

+CC Mark Brown,

Ugh, I see more of commits from this patchset getting to mainline twice. One branch goes to Linus via 79f20778fb228ae372cd7602745382fd4543ef31 Merge tag 'regulator-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
which is based on v4.20-rc1

The other commits gets there via:
68cc38ff33f38424d0456f9a1ecfec4683226a7e Merge tag 'regulator-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
which is before (gets into v4.18-rc1).

Quoted 6 lines

But how the latter can be applied again if it is based on something already containing these commits... I am so confused...

Anyway the Fixes needs to be corrected to contain both (also 0369e02b75e6) and should be backported to v4.19... I'll see if I have spare time to make a backport.

Ah, I see now revert of the first commit 37fa23dbccbd97663acc085bd79246f427e603a1 (regulator: s2mps11: Fix boot on Odroid XU3). Actually git diff points that there was no effective change in the s2mps11 regulator.

Since the revert got into v4.18, then v4.19 is safe and there is no need for backport.

Best regards,
Krzysztof