public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: handle missing regmap
@ 2026-04-07 12:41 Matti Vaittinen
  2026-04-08  7:18 ` Bartosz Golaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Matti Vaittinen @ 2026-04-07 12:41 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen
  Cc: Matti Vaittinen, Linus Walleij, Bartosz Golaszewski, linux-gpio,
	linux-kernel, Andreas Kemnade

[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]

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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-08  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 12:41 [PATCH] gpio: handle missing regmap Matti Vaittinen
2026-04-08  7:18 ` Bartosz Golaszewski
2026-04-08  7:43   ` Matti Vaittinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox