• Linus Walleij's avatar
    mtd: afs: simplify partition parsing · 1fca1f6a
    Linus Walleij authored
    This simplifies the AFS partition parsing to make the code
    more straight-forward and readable.
    
    Before this patch the code tried to calculate the memory required
    to hold the partition info by adding up the sizes of the strings
    of the names and adding that to a single memory allocation,
    indexing the name pointers in front of the struct mtd_partition
    allocations so all allocated data was in one chunk.
    
    This is overzealous. Instead use kstrdup and bail out,
    kfree():ing the memory used for MTD partitions and names alike
    on the errorpath.
    
    In the process rename the index variable from idx to i.
    
    Cc: Ryan Harkin <ryan.harkin@linaro.org>
    Acked-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    1fca1f6a
afs.c 6.22 KB