linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: nomadik: fix dereference of error pointer
@ 2024-03-06 16:19 Théo Lebrun
  2024-03-06 19:47 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Théo Lebrun @ 2024-03-06 16:19 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, Gregory CLEMENT, Dan Carpenter, Théo Lebrun

If nmk_gpio_populate_chip() returns an error, avoid deferencing its
return value.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-gpio/5ee722f8-7582-420d-8477-45be6acde90f@moroto.mountain/
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
Fix a smatch-reported potential bug. Thanks Dan for the bug report.
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index 47d5484f6bdf..cb0f0d5a5e45 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -1228,9 +1228,10 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
 		if (IS_ERR(nmk_chip))
 			dev_err(&pdev->dev,
 				"could not populate nmk chip struct - continue anyway\n");
+		else
+			/* We are NOT compatible with mobileye,eyeq5-gpio. */
+			BUG_ON(nmk_chip->is_mobileye_soc);
 		fwnode_handle_put(gpio_fwnode);
-		/* We are NOT compatible with mobileye,eyeq5-gpio. */
-		BUG_ON(nmk_chip->is_mobileye_soc);
 	}
 
 	prcm_fwnode = fwnode_find_reference(fwnode, "prcm", 0);

---
base-commit: 7d2b279d9db028a2c1095668296defb18aabcb0f
change-id: 20240306-mbly-gpio-err-fix-533118c7fe7a

Best regards,
-- 
Théo Lebrun <theo.lebrun@bootlin.com>


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

end of thread, other threads:[~2024-03-06 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 16:19 [PATCH] pinctrl: nomadik: fix dereference of error pointer Théo Lebrun
2024-03-06 19:47 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).