lib/mpi: checks for zero divisor length
authorDmitry Kasatkin <dmitry.kasatkin@intel.com>
Thu, 26 Jan 2012 17:13:22 +0000 (19:13 +0200)
committerJames Morris <jmorris@namei.org>
Wed, 1 Feb 2012 13:23:14 +0000 (00:23 +1100)
Divisor length should not be 0.

Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Reviewed-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
lib/mpi/mpi-div.c

index c3087d1390ce5d1b669ce7f1326b4eaf079d2caa..8a45717bd001e0ea36855de0ba2312e07983d92b 100644 (file)
@@ -149,6 +149,9 @@ int mpi_tdiv_qr(MPI quot, MPI rem, MPI num, MPI den)
        mpi_ptr_t marker[5];
        int markidx = 0;
 
+       if (!dsize)
+               return -EINVAL;
+
        memset(marker, 0, sizeof(marker));
 
        /* Ensure space is enough for quotient and remainder.