• Wen Yang's avatar
    coccinelle: semantic patch to check for inappropriate do_div() calls · ac5f3136
    Wen Yang authored
    do_div() does a 64-by-32 division.
    When the divisor is unsigned long, u64, or s64,
    do_div() truncates it to 32 bits, this means it
    can test non-zero and be truncated to zero for division.
    This semantic patch is inspired by Mateusz Guzik's patch:
    commit b0ab99e7 ("sched: Fix possible divide by zero in avg_atom() calculation")
    Signed-off-by: default avatarWen Yang <wenyang@linux.alibaba.com>
    Signed-off-by: default avatarJulia Lawall <julia.lawall@inria.fr>
    Cc: Gilles Muller <Gilles.Muller@lip6.fr>
    Cc: Nicolas Palix <nicolas.palix@imag.fr>
    Cc: Michal Marek <michal.lkml@markovi.net>
    Cc: Matthias Maennich <maennich@google.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: cocci@systeme.lip6.fr
    Cc: linux-kernel@vger.kernel.org
    ac5f3136
do_div.cocci 3.48 KB