On Fri, Jun 17, 2016 at 11:28 AM, walter harms <wharms@xxxxxx> wrote: > Am 17.06.2016 11:15, schrieb Dan Carpenter: >> out_free_descs: >> + if (i == GPIOHANDLES_MAX) >> + i--; >> for (; i >= 0; i--) >> gpiod_free(lh->descs[i]); >> kfree(lh->label); > > > Since we have already noticed that programmes are bad at counting backwards > is it possible to change the loop into counting up ? > > btw: if lh->descs[i] is initialized to NULL it would be more robust just to free everything like: > > for(i=0;i< GPIOHANDLES_MAX; i++) > gpiod_free(lh->descs[i]); > > just my two cents, The loop looks like that for a reason: i is indexing upwards while grabbing the descriptors, then it rewinds that way to free them if something went wrong during init. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html