diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-09-07 10:29:26 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-09-12 11:26:40 +0200 |
commit | 41470c379b4f8d9a1513d930338fadfbccc287b6 (patch) | |
tree | 5e82a8715fb7d81877734b05834ab458b7e1b457 /drivers/pinctrl | |
parent | baec7e687aa066f6fa257222a0def5ea9b5b1c40 (diff) | |
download | linux-stable-41470c379b4f8d9a1513d930338fadfbccc287b6.tar.gz linux-stable-41470c379b4f8d9a1513d930338fadfbccc287b6.tar.bz2 linux-stable-41470c379b4f8d9a1513d930338fadfbccc287b6.zip |
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>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/sprd/pinctrl-sprd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c index c178b4a6d7f5..e52a01e1f662 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"); |