Skip to content

Commit

Permalink
lib/digsig: checks for NULL return value
Browse files Browse the repository at this point in the history
mpi_read_from_buffer() return value must not be NULL.

Signed-off-by: Dmitry Kasatkin <[email protected]>
Reviewed-by: Tetsuo Handa <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Dmitry Kasatkin authored and James Morris committed Feb 1, 2012
1 parent 43b2c0a commit 86f8bed
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/digsig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -168,8 +172,8 @@ static int digsig_verify_rsa(struct key *key,
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);

Expand Down

0 comments on commit 86f8bed

Please sign in to comment.