From patchwork Thu Jul 9 14:57:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 493456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 96FF91402B1 for ; Fri, 10 Jul 2015 00:57:45 +1000 (AEST) Received: from localhost ([::1]:40318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDDGh-000689-Re for incoming@patchwork.ozlabs.org; Thu, 09 Jul 2015 10:57:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDDGI-0005Wz-Ed for qemu-devel@nongnu.org; Thu, 09 Jul 2015 10:57:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDDGF-0002oM-KH for qemu-devel@nongnu.org; Thu, 09 Jul 2015 10:57:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDDGF-0002oI-FD for qemu-devel@nongnu.org; Thu, 09 Jul 2015 10:57:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id F36042D4512 for ; Thu, 9 Jul 2015 14:57:14 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-32.ams2.redhat.com [10.36.112.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t69EvA2e023353 for ; Thu, 9 Jul 2015 10:57:14 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 9 Jul 2015 16:57:10 +0200 Message-Id: <1436453830-4700-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1436453830-4700-1-git-send-email-pbonzini@redhat.com> References: <1436453830-4700-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/2] crypto: fix builtin qcrypto_cipher_free X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was dereferencing a pointer before checking if it was NULL. Reported-by: Christian Borntraeger Reported-by: Aurelien Jarno Signed-off-by: Paolo Bonzini Reviewed-by: Aurelien Jarno Tested-by: Aurelien Jarno --- crypto/cipher-builtin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index c625cb4..912c1b9 100644 --- a/crypto/cipher-builtin.c +++ b/crypto/cipher-builtin.c @@ -354,11 +354,13 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, void qcrypto_cipher_free(QCryptoCipher *cipher) { - QCryptoCipherBuiltin *ctxt = cipher->opaque; + QCryptoCipherBuiltin *ctxt; + if (!cipher) { return; } + ctxt = cipher->opaque; ctxt->free(cipher); g_free(cipher); }