[PATCH] gpio: handle missing regmap

From: Matti Vaittinen

Date: Tue Apr 07 2026 - 08:43:52 EST


From: Matti Vaittinen <mazziesaccount@xxxxxxxxx>

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@xxxxxxxxx>
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

Attachment: signature.asc
Description: PGP signature