diff mbox

[PULL,2/2] crypto: fix builtin qcrypto_cipher_free

Message ID 1436453830-4700-3-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini July 9, 2015, 2:57 p.m. UTC
This was dereferencing a pointer before checking if it was NULL.

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reported-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 crypto/cipher-builtin.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Aurelien Jarno July 9, 2015, 3:04 p.m. UTC | #1
On 2015-07-09 16:57, Paolo Bonzini wrote:
> This was dereferencing a pointer before checking if it was NULL.
> 
> Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reported-by: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  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);
>  }

Thanks for the quick fix.

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
diff mbox

Patch

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);
 }