On Mon, May 9, 2016 at 9:34 AM, Pantelis Antoniou <pantelis.antoniou@xxxxxxxxxxxx> wrote: > Hi Rob, > >> On May 9, 2016, at 17:27 , Rob Herring <robherring2@xxxxxxxxx> wrote: >> >> On Mon, May 9, 2016 at 8:20 AM, Pantelis Antoniou >> <pantelis.antoniou@xxxxxxxxxxxx> 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; >>> +} -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html