diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-06-06 09:43:38 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-06-18 01:55:56 -0400 |
commit | 7f57871f39912978e95db920ddbbfb2304a4bfbf (patch) | |
tree | e3c35483aa91dc6a39f263c6a36ca7056f2721a2 | |
parent | bc3322bc166a2905bc91f774d7b22773dc7c063a (diff) |
pinctrl: single: Add allocation failure checking of saved_vals
Currently saved_vals is being allocated and there is no check for
failed allocation (which is more likely than normal when using
GFP_ATOMIC). Fix this by checking for a failed allocation and
propagating this error return down the the caller chain.
Detected by CoverityScan, CID#1469841 ("Dereference null return value")
Fixes: 88a1dbdec682 ("pinctrl: pinctrl-single: Add functions to save and restore pinctrl context")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-single.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index b3153c095199..e5647dac0818 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c | |||
@@ -1590,8 +1590,11 @@ static int pcs_save_context(struct pcs_device *pcs) | |||
1590 | 1590 | ||
1591 | mux_bytes = pcs->width / BITS_PER_BYTE; | 1591 | mux_bytes = pcs->width / BITS_PER_BYTE; |
1592 | 1592 | ||
1593 | if (!pcs->saved_vals) | 1593 | if (!pcs->saved_vals) { |
1594 | pcs->saved_vals = devm_kzalloc(pcs->dev, pcs->size, GFP_ATOMIC); | 1594 | pcs->saved_vals = devm_kzalloc(pcs->dev, pcs->size, GFP_ATOMIC); |
1595 | if (!pcs->saved_vals) | ||
1596 | return -ENOMEM; | ||
1597 | } | ||
1595 | 1598 | ||
1596 | switch (pcs->width) { | 1599 | switch (pcs->width) { |
1597 | case 64: | 1600 | case 64: |
@@ -1651,8 +1654,13 @@ static int pinctrl_single_suspend(struct platform_device *pdev, | |||
1651 | if (!pcs) | 1654 | if (!pcs) |
1652 | return -EINVAL; | 1655 | return -EINVAL; |
1653 | 1656 | ||
1654 | if (pcs->flags & PCS_CONTEXT_LOSS_OFF) | 1657 | if (pcs->flags & PCS_CONTEXT_LOSS_OFF) { |
1655 | pcs_save_context(pcs); | 1658 | int ret; |
1659 | |||
1660 | ret = pcs_save_context(pcs); | ||
1661 | if (ret < 0) | ||
1662 | return ret; | ||
1663 | } | ||
1656 | 1664 | ||
1657 | return pinctrl_force_sleep(pcs->pctl); | 1665 | return pinctrl_force_sleep(pcs->pctl); |
1658 | } | 1666 | } |