pinctrl: sprd: check for allocation failure

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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Dan Carpenter and committed by
Linus Walleij
41470c37 baec7e68

+7 -3
+7 -3
drivers/pinctrl/sprd/pinctrl-sprd.c
··· 1100 1100 1101 1101 void sprd_pinctrl_shutdown(struct platform_device *pdev) 1102 1102 { 1103 - struct pinctrl *pinctl = devm_pinctrl_get(&pdev->dev); 1103 + struct pinctrl *pinctl; 1104 1104 struct pinctrl_state *state; 1105 1105 1106 + pinctl = devm_pinctrl_get(&pdev->dev); 1107 + if (IS_ERR(pinctl)) 1108 + return; 1106 1109 state = pinctrl_lookup_state(pinctl, "shutdown"); 1107 - if (!IS_ERR(state)) 1108 - pinctrl_select_state(pinctl, state); 1110 + if (IS_ERR(state)) 1111 + return; 1112 + pinctrl_select_state(pinctl, state); 1109 1113 } 1110 1114 1111 1115 MODULE_DESCRIPTION("SPREADTRUM Pin Controller Driver");