Commit 7f57871f authored by Colin Ian King's avatar Colin Ian King Committed by Linus Walleij

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: 88a1dbde ("pinctrl: pinctrl-single: Add functions to save and restore pinctrl context")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Reviewed-by: default avatarJohan Hovold <johan@kernel.org>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent bc3322bc
...@@ -1590,8 +1590,11 @@ static int pcs_save_context(struct pcs_device *pcs) ...@@ -1590,8 +1590,11 @@ static int pcs_save_context(struct pcs_device *pcs)
mux_bytes = pcs->width / BITS_PER_BYTE; mux_bytes = pcs->width / BITS_PER_BYTE;
if (!pcs->saved_vals) if (!pcs->saved_vals) {
pcs->saved_vals = devm_kzalloc(pcs->dev, pcs->size, GFP_ATOMIC); pcs->saved_vals = devm_kzalloc(pcs->dev, pcs->size, GFP_ATOMIC);
if (!pcs->saved_vals)
return -ENOMEM;
}
switch (pcs->width) { switch (pcs->width) {
case 64: case 64:
...@@ -1651,8 +1654,13 @@ static int pinctrl_single_suspend(struct platform_device *pdev, ...@@ -1651,8 +1654,13 @@ static int pinctrl_single_suspend(struct platform_device *pdev,
if (!pcs) if (!pcs)
return -EINVAL; return -EINVAL;
if (pcs->flags & PCS_CONTEXT_LOSS_OFF) if (pcs->flags & PCS_CONTEXT_LOSS_OFF) {
pcs_save_context(pcs); int ret;
ret = pcs_save_context(pcs);
if (ret < 0)
return ret;
}
return pinctrl_force_sleep(pcs->pctl); return pinctrl_force_sleep(pcs->pctl);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment