From: Dmitry Kasatkin Date: Thu, 26 Jan 2012 17:13:19 +0000 (+0200) Subject: lib/mpi: check for possible zero length X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4877e056192245b387aae004ab38f7f3899dd57c;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git lib/mpi: check for possible zero length Buggy client might pass zero nlimbs which is meaningless. Added check for zero length. Signed-off-by: Dmitry Kasatkin Reviewed-by: Tetsuo Handa Signed-off-by: James Morris --- diff --git a/lib/mpi/mpiutil.c b/lib/mpi/mpiutil.c index 6bfc41f62b8f..26e4ed31e256 100644 --- a/lib/mpi/mpiutil.c +++ b/lib/mpi/mpiutil.c @@ -58,6 +58,9 @@ mpi_ptr_t mpi_alloc_limb_space(unsigned nlimbs) { size_t len = nlimbs * sizeof(mpi_limb_t); + if (!len) + return NULL; + return kmalloc(len, GFP_KERNEL); }