summaryrefslogtreecommitdiffstats
path: root/lib/digsig.c
diff options
context:
space:
mode:
authorDmitry Kasatkin <dmitry.kasatkin@intel.com>2012-01-26 19:13:24 +0200
committerJames Morris <jmorris@namei.org>2012-02-02 00:24:04 +1100
commit86f8bedc9e1a8ddb4f1d9ff1f0c1229cc0797d6d (patch)
treea0b67fa9e778cba871b8135cf6976066d11af83b /lib/digsig.c
parent43b2c0aeaab2237996a72f9b9d7952ba82d56913 (diff)
downloadop-kernel-dev-86f8bedc9e1a8ddb4f1d9ff1f0c1229cc0797d6d.zip
op-kernel-dev-86f8bedc9e1a8ddb4f1d9ff1f0c1229cc0797d6d.tar.gz
lib/digsig: checks for NULL return value
mpi_read_from_buffer() return value must not be NULL. 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>
Diffstat (limited to 'lib/digsig.c')
-rw-r--r--lib/digsig.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/digsig.c b/lib/digsig.c
index b67e82c..286d558 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);
OpenPOWER on IntegriCloud