lkml.org 
[lkml]   [2016]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/4] of: changesets: Introduce changeset helper methods
On Mon, May 9, 2016 at 9:34 AM, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Hi Rob,
>
>> On May 9, 2016, at 17:27 , Rob Herring <robherring2@gmail.com> wrote:
>>
>> On Mon, May 9, 2016 at 8:20 AM, Pantelis Antoniou
>> <pantelis.antoniou@konsulko.com> wrote:
>>> Changesets are very powerful, but the lack of a helper API
>>> makes using them cumbersome. Introduce a simple copy based
>>> API that makes things considerably easier.

[...]

>>> + /*
>>> + * NOTE: There is no check for zero length value.
>>> + * In case of a boolean property, this will allocate a value
>>> + * of zero bytes. We do this to work around the use
>>> + * of of_get_property() calls on boolean values.
>>> + */
>>> + new_value = kmemdup(value, length, GFP_KERNEL);
>>> + if (!new_value)
>>> + goto out_no_value;
>>> +
>>> + of_property_set_flag(prop, OF_DYNAMIC);
>>> +
>>> + prop->name = new_name;
>>> + prop->value = new_value;
>>> + prop->length = length;
>>> +
>>> + if (!update)
>>> + ret = of_changeset_add_property(ocs, np, prop);
>>> + else
>>> + ret = of_changeset_update_property(ocs, np, prop);
>>> +
>>> + if (ret != 0)
>>
>> if (!ret)
>> return 0;
>>
>>
>
>>> + goto out_no_add;
>>> +
>>> + return 0;
>>> +
>>> +out_no_add:
>>
>> ... and remove all this.
>>
>
> Err, there’s an exit path here from kmemdup (goto err_no_value).
> We’ll be leaking memory on error.

No you won't. "This" is the hunk above it. The error handling would
still be here:

>>> + kfree(prop->value);
>>> +out_no_value:
>>> + kfree(prop->name);
>>> +out_no_name:
>>> + kfree(prop);
>>> +out_no_prop:
>>> + return ret;
>>> +}

\
 
 \ /
  Last update: 2016-05-09 17:21    [W:0.053 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site