]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
lib/digsig: checks for NULL return value
authorDmitry Kasatkin <dmitry.kasatkin@intel.com>
Thu, 26 Jan 2012 17:13:24 +0000 (19:13 +0200)
committerJames Morris <jmorris@namei.org>
Wed, 1 Feb 2012 13:24:04 +0000 (00:24 +1100)
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>
lib/digsig.c

index b67e82c024b3f2882bfecbc23bd3ac9ae41d07ab..286d558033e270524ff3fdeac9c96393b81170a6 100644 (file)
@@ -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);