• Kees Cook's avatar
    treewide: kmalloc() -> kmalloc_array() · 6da2ec56
    Kees Cook authored
    The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:
            kmalloc(a * b, gfp)
            kmalloc_array(a * b, gfp)
    as well as handling cases of:
            kmalloc(a * b * c, gfp)
            kmalloc(array3_size(a, b, c), gfp)
    as it's slightly less ugly than:
            kmalloc_array(array_size(a, b), c, gfp)
    This does, however, attempt to ignore constant size factors like:
            kmalloc(4 * 1024, gfp)
    though any constants defined via macros get caught up in the conversion.
    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.
    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().
    The Coccinelle script used for this was:
    // Fix redundant parens around sizeof().
    type TYPE;
    expression THING, E;
    -	(sizeof(TYPE)) * E
    +	sizeof(TYPE) * E
      , ...)
    -	(sizeof(THING)) * E
    +	sizeof(THING) * E
pgd.c 3.66 KB