staging: ccree: fix leak of import() after init()
authorGilad Ben-Yossef <gilad@benyossef.com>
Thu, 9 Nov 2017 09:16:09 +0000 (09:16 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Dec 2017 12:40:44 +0000 (13:40 +0100)
commita633c7ed4a4c6097475de05d950e35cf92b8dec7
tree6d529f7a12cb9d7dfc3c0b45729180ddf5794479
parent779bfa90bdf97a6d00459471f6d371f6036f3da5
staging: ccree: fix leak of import() after init()

commit c5f39d07860c35e5e4c63188139465af790f86ce upstream.

crypto_ahash_import() may be called either after
crypto_ahash_init() or without such call. Right now
we always internally call init() as part of
import(), thus leaking memory and mappings if the
user has already called init() herself.

Fix this by only calling init() internally if the
state is not already initialized.

Fixes: commit 454527d0d94f ("staging: ccree: fix hash import/export")
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ccree/ssi_hash.c