From: Dmitry Kasatkin Date: Thu, 26 Jan 2012 17:13:19 +0000 (+0200) Subject: lib/mpi: check for possible zero length X-Git-Tag: v3.3-rc3~39^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4877e056192245b387aae004ab38f7f3899dd57c;p=profile%2Fcommon%2Fkernel-common.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 6bfc41f..26e4ed3 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); }