lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55AE8864.6020608@codeaurora.org>
Date:	Tue, 21 Jul 2015 10:59:00 -0700
From:	Stephen Boyd <sboyd@...eaurora.org>
To:	Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
CC:	linux-arm-kernel@...ts.infradead.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Rob Herring <robh+dt@...nel.org>,
	Mark Brown <broonie@...nel.org>, s.hauer@...gutronix.de,
	linux-api@...r.kernel.org, linux-kernel@...r.kernel.org,
	devicetree@...r.kernel.org, linux-arm-msm@...r.kernel.org,
	arnd@...db.de, pantelis.antoniou@...sulko.com,
	mporter@...sulko.com, stefan.wahren@...e.com, wxt@...k-chips.com,
	Maxime Ripard <maxime.ripard@...e-electrons.com>
Subject: Re: [PATCH v8 1/9] nvmem: Add a simple NVMEM framework for nvmem
 providers

On 07/21/2015 02:41 AM, Srinivas Kandagatla wrote:
> Thanks Stephen for review,
>
> On 20/07/15 22:11, Stephen Boyd wrote:
>> On 07/20/2015 07:43 AM, Srinivas Kandagatla wrote:
>>> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
>>> new file mode 100644
>>> index 0000000..bde5528
>>> --- /dev/null
>>> +++ b/drivers/nvmem/core.c
>>> @@ -0,0 +1,384 @@
>>>
>>> +
>>> +static int nvmem_add_cells(struct nvmem_device *nvmem,
>>> +               const struct nvmem_config *cfg)
>>> +{
>>> +    struct nvmem_cell **cells;
>>> +    const struct nvmem_cell_info *info = cfg->cells;
>>> +    int i, rval;
>>> +
>>> +    cells = kzalloc(sizeof(*cells) * cfg->ncells, GFP_KERNEL);
>>
>> kcalloc?
>
> Only reason for using kzalloc is to give the code more flexibility to 
> free any pointer in the array in case of errors.

Still lost. The arrays are allocated down below in the for loop. This is 
allocating a bunch of pointers so using kcalloc() here avoids problems 
with overflows causing kzalloc() to allocate fewer pointers than 
requested. I'm not suggesting we replace the for loop with a kcalloc, 
just this single line.

>
>>
>>> +    if (!cells)
>>> +        return -ENOMEM;
>>> +
>>> +    for (i = 0; i < cfg->ncells; i++) {
>>> +        cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL);
>>> +        if (!cells[i]) {
>>> +            rval = -ENOMEM;
>>> +            goto err;
>>> +        }
>>> +

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ