If a memory allocation fails, we should go through the error handling path, as done elsewhere in this 'for' loop. Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> --- drivers/regulator/qcom_spmi-regulator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/qcom_spmi-regulator.c b/drivers/regulator/qcom_spmi-regulator.c index 16c5f84e06a7..fbe908a37daa 100644 --- a/drivers/regulator/qcom_spmi-regulator.c +++ b/drivers/regulator/qcom_spmi-regulator.c @@ -1657,8 +1657,10 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) for (reg = match->data; reg->name; reg++) { vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); - if (!vreg) - return -ENOMEM; + if (!vreg) { + ret = -ENOMEM; + goto err; + } vreg->dev = dev; vreg->base = reg->base; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html