Commit 176cf704 authored by Pi-Hsun Shih's avatar Pi-Hsun Shih Committed by Mark Brown

regulator: cros-ec-regulator: Fix double free of desc->name.

The desc->name field is allocated with devm_kstrdup, but is also kfreed
on the error path, causing it to be double freed. Remove the kfree on
the error path.

Fixes: 8d9f8d57 ("regulator: Add driver for cros-ec-regulator")
Signed-off-by: default avatarPi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20200728091909.2009771-1-pihsun@chromium.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a2335476
......@@ -222,18 +222,13 @@ static int cros_ec_regulator_probe(struct platform_device *pdev)
drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg);
if (IS_ERR(drvdata->dev)) {
ret = PTR_ERR(drvdata->dev);
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
goto free_name;
return PTR_ERR(drvdata->dev);
}
platform_set_drvdata(pdev, drvdata);
return 0;
free_name:
kfree(desc->name);
return ret;
}
static const struct of_device_id regulator_cros_ec_of_match[] = {
......
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