summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/digsig.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/digsig.c b/lib/digsig.c
index b67e82c024b3..286d558033e2 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -109,9 +109,13 @@ static int digsig_verify_rsa(struct key *key,
datap = pkh->mpi;
endp = ukp->data + ukp->datalen;
+ err = -ENOMEM;
+
for (i = 0; i < pkh->nmpi; i++) {
unsigned int remaining = endp - datap;
pkey[i] = mpi_read_from_buffer(datap, &remaining);
+ if (!pkey[i])
+ goto err;
datap += remaining;
}
@@ -168,8 +172,8 @@ err:
mpi_free(res);
kfree(out1);
kfree(out2);
- mpi_free(pkey[0]);
- mpi_free(pkey[1]);
+ while (--i >= 0)
+ mpi_free(pkey[i]);
err1:
up_read(&key->sem);