Re: [PATCH v5 2/3] cxlflash: Superpipe support

Manoj Kumar
2015-08-13T23:38:56Z

Mikey:

Good catch. Will resolve this in the v6 patch.

Thanks,
- Manoj

On 8/13/2015 5:53 AM, Michael Neuling wrote:

>> +
>> + ctxi = kzalloc(sizeof(*ctxi), GFP_KERNEL);
>> + lli = kzalloc((MAX_RHT_PER_CONTEXT * sizeof(*lli)), GFP_KERNEL);
>> + if (unlikely(!ctxi || !lli)) {
>> + dev_err(dev, "%s: Unable to allocate context!\n", __func__);
>> + goto out;
>
> If only one of these allocations fails you'll leak some memory. I
> suggest making this "goto err", remove the "out" label and make err
> look like this:
>
> err:
> if lli
> kfree(lli);
> if ctxi
> kfree(ctxi);
> return NULL;

Since kfree() handles being passed a NULL pointer, we will change this
also to 'goto err'.