All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: sprd: check for allocation failure
@ 2017-09-07  7:29 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-09-07  7:29 UTC (permalink / raw)
  To: Linus Walleij, Baolin Wang; +Cc: linux-gpio, kernel-janitors

devm_pinctrl_get() could fail with ERR_PTR(-ENOMEM) so I have added a
check for that.  I also reversed the other IS_ERR() test because it was
a little confusing to test one way and then the opposite a couple lines
later.

Fixes: 41d32cfce1ae ("pinctrl: sprd: Add Spreadtrum pin control driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index 7e7b9ac7e836..673b77bbbc8c 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -1100,12 +1100,16 @@ int sprd_pinctrl_remove(struct platform_device *pdev)
 
 void sprd_pinctrl_shutdown(struct platform_device *pdev)
 {
-	struct pinctrl *pinctl = devm_pinctrl_get(&pdev->dev);
+	struct pinctrl *pinctl;
 	struct pinctrl_state *state;
 
+	pinctl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(pinctl))
+		return;
 	state = pinctrl_lookup_state(pinctl, "shutdown");
-	if (!IS_ERR(state))
-		pinctrl_select_state(pinctl, state);
+	if (IS_ERR(state))
+		return;
+	pinctrl_select_state(pinctl, state);
 }
 
 MODULE_DESCRIPTION("SPREADTRUM Pin Controller Driver");

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

end of thread, other threads:[~2017-09-12  9:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-07  7:29 [PATCH 1/2] pinctrl: sprd: check for allocation failure Dan Carpenter
2017-09-07  7:29 ` Dan Carpenter
2017-09-07 11:12 ` [PATCH 2/2] pinctrl: sprd: fix off by one bugs Dan Carpenter
2017-09-07 11:12   ` Dan Carpenter
2017-09-07 11:29   ` Baolin Wang
2017-09-07 11:29     ` Baolin Wang
2017-09-12  9:28   ` Linus Walleij
2017-09-12  9:28     ` Linus Walleij
2017-09-12  9:27 ` [PATCH 1/2] pinctrl: sprd: check for allocation failure Linus Walleij
2017-09-12  9:27   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.