Re: [PATCH v2 07/14] regulator: s2mps11: Copy supported regulators from initconst

Mark Brown
2014-02-13T19:29:27Z

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

On Thu, Feb 13, 2014 at 10:14:00AM +0100, Krzysztof Kozlowski wrote:

> - for (i = 0; i < S2MPS11_REGULATOR_CNT; i++)
> + s2mps11->rdev = devm_kzalloc(&pdev->dev,
> + sizeof(*s2mps11->rdev)*rdev_num, GFP_KERNEL);
> + if (!s2mps11->rdev)
> + return -ENOMEM;

If we're using managed allocations do we actually need to keep the rdev
table at all? We only normally use it to free.

> + rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata)*rdev_num, GFP_KERNEL);
> + if (!rdata)
> + return -ENOMEM;
> +

> + /* rdata was needed only for of_regulator_match() during probe */
> + if (rdata)
> + devm_kfree(&pdev->dev, rdata);
> +

If this is always going to be freed within the probe path (in the same
function indeed) why is it a managed allocaton at all?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]