summaryrefslogtreecommitdiffstats
path: root/lib/mpi/mpi-div.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2012-02-28 13:48:58 -0600
committerGrant Likely <grant.likely@secretlab.ca>2012-02-28 13:48:58 -0600
commitb3950d50cfc343b3e7dc5c69c96a61b182fd1e37 (patch)
treed54affae2b1e25464493b48aa88cd8d6b4770812 /lib/mpi/mpi-div.c
parentdaefd89efc279b142bbb054577c2d706da211723 (diff)
parent280ad7fda5f95211857fda38960f2b6fdf6edd3e (diff)
downloadop-kernel-dev-b3950d50cfc343b3e7dc5c69c96a61b182fd1e37.zip
op-kernel-dev-b3950d50cfc343b3e7dc5c69c96a61b182fd1e37.tar.gz
Merge branch 'irqdomain/next' into gpio/next
Diffstat (limited to 'lib/mpi/mpi-div.c')
-rw-r--r--lib/mpi/mpi-div.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/mpi/mpi-div.c b/lib/mpi/mpi-div.c
index c3087d1..f68cbbb 100644
--- a/lib/mpi/mpi-div.c
+++ b/lib/mpi/mpi-div.c
@@ -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.
@@ -207,6 +210,8 @@ int mpi_tdiv_qr(MPI quot, MPI rem, MPI num, MPI den)
* numerator would be gradually overwritten by the quotient limbs. */
if (qp == np) { /* Copy NP object to temporary space. */
np = marker[markidx++] = mpi_alloc_limb_space(nsize);
+ if (!np)
+ goto nomem;
MPN_COPY(np, qp, nsize);
}
} else /* Put quotient at top of remainder. */
OpenPOWER on IntegriCloud