From patchwork Thu Aug 11 12:18:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Savkov X-Patchwork-Id: 9275183 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81A926022E for ; Thu, 11 Aug 2016 12:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F30D28609 for ; Thu, 11 Aug 2016 12:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6008628626; Thu, 11 Aug 2016 12:20:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1330728609 for ; Thu, 11 Aug 2016 12:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752041AbcHKMT7 (ORCPT ); Thu, 11 Aug 2016 08:19:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57216 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbcHKMT6 (ORCPT ); Thu, 11 Aug 2016 08:19:58 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3287761E44; Thu, 11 Aug 2016 12:19:09 +0000 (UTC) Received: from shodan.usersys.redhat.com (dhcp-1-150.brq.redhat.com [10.34.1.150]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7BCJ8DU020411; Thu, 11 Aug 2016 08:19:08 -0400 Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id C75A62C5037; Thu, 11 Aug 2016 14:19:07 +0200 (CEST) From: Artem Savkov To: tadeusz.struk@intel.com Cc: dhowells@redhat.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH] X.509: Fix double free in x509_cert_parse(). Date: Thu, 11 Aug 2016 14:18:56 +0200 Message-Id: <1470917936-23904-1-git-send-email-asavkov@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 Aug 2016 12:19:09 +0000 (UTC) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch "crypto: KEYS: convert public key and digsig asym to the akcipher api" introduced double freeing of cert->pub->key. There is no need to free it in error_decode label as it is later freed in x509_free_certificate(). Signed-off-by: Artem Savkov --- crypto/asymmetric_keys/x509_cert_parser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c index 1f1899d..9157071 100644 --- a/crypto/asymmetric_keys/x509_cert_parser.c +++ b/crypto/asymmetric_keys/x509_cert_parser.c @@ -133,7 +133,6 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen) return cert; error_decode: - kfree(cert->pub->key); kfree(ctx); error_no_ctx: x509_free_certificate(cert);