[PATCH] gpio: handle missing regmap

Matti Vaittinen posted 1 patch 2 months, 2 weeks ago
drivers/gpio/gpio-bd72720.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] gpio: handle missing regmap
Posted by Matti Vaittinen 2 months, 2 weeks ago
From: Matti Vaittinen <mazziesaccount@gmail.com>

Currently the probe does not check whether getting the regmap succeeded.
This can cause crash when regmap is used, if it wasn't successfully
obtained. Failing to get the regmap is unlikely, especially since this
driver is expected to be kicked by the MFD driver only after registering
the regmap - but it is still better to handle this gracefully.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: e7eef0bd4075 ("regulator: bd71828-regulator.c: Fix LDON-HEAD mode")

---
As mentioned, this is really not likely to happen. Hence, I am not sure
it needs to be backported or whether to add the Fixes tag or not. OTOH,
fix is very trivial and unlikely to conflict - so maybe it's better to
just backport it.

---
 drivers/gpio/gpio-bd72720.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-bd72720.c b/drivers/gpio/gpio-bd72720.c
index 6549dbf4c7ad..d0f936ed80af 100644
--- a/drivers/gpio/gpio-bd72720.c
+++ b/drivers/gpio/gpio-bd72720.c
@@ -256,6 +256,8 @@ static int gpo_bd72720_probe(struct platform_device *pdev)
 	g->dev = dev;
 	g->chip.parent = parent;
 	g->regmap = dev_get_regmap(parent, NULL);
+	if (!g->regmap)
+		return -ENODEV;
 
 	return devm_gpiochip_add_data(dev, &g->chip, g);
 }

base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c
-- 
2.53.0

Re: [PATCH] gpio: handle missing regmap
Posted by Bartosz Golaszewski 2 months, 1 week ago
On Tue, 07 Apr 2026 15:41:48 +0300, Matti Vaittinen wrote:
> Currently the probe does not check whether getting the regmap succeeded.
> This can cause crash when regmap is used, if it wasn't successfully
> obtained. Failing to get the regmap is unlikely, especially since this
> driver is expected to be kicked by the MFD driver only after registering
> the regmap - but it is still better to handle this gracefully.
> 
> 
> [...]

The subject should have been: "gpio: bd72720: handle missing regmap".

I fixed it and queued the patch.

[1/1] gpio: handle missing regmap
      https://git.kernel.org/brgl/c/828ec7f803f41588a120e6d804297e74a482ab9d

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Re: [PATCH] gpio: handle missing regmap
Posted by Matti Vaittinen 2 months, 1 week ago
On 08/04/2026 10:18, Bartosz Golaszewski wrote:
> 
> On Tue, 07 Apr 2026 15:41:48 +0300, Matti Vaittinen wrote:
>> Currently the probe does not check whether getting the regmap succeeded.
>> This can cause crash when regmap is used, if it wasn't successfully
>> obtained. Failing to get the regmap is unlikely, especially since this
>> driver is expected to be kicked by the MFD driver only after registering
>> the regmap - but it is still better to handle this gracefully.
>>
>>
>> [...]
> 
> The subject should have been: "gpio: bd72720: handle missing regmap".

Indeed!

> I fixed it and queued the patch.

Thanks a bunch :)

Yours,
   -- Matti


---
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~