crypto: qat - return proper error code in setkey
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Mon, 29 Apr 2019 15:43:19 +0000 (16:43 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 23 May 2019 06:01:03 +0000 (14:01 +0800)
commit92fec16d1f4d852711511844b02f5353825d1578
tree4eb64c2496dbda483b1ee2c5ac29937028eb6bf5
parent51d33c2f05edeace67e6f7f0603dc7aa4667e9a6
crypto: qat - return proper error code in setkey

If an invalid key is provided as input to the setkey function, the
function always failed returning -ENOMEM rather than -EINVAL.
Furthermore, if setkey was called multiple times with an invalid key,
the device instance was getting leaked.

This patch fixes the error paths in the setkey functions by returning
the correct error code in case of error and freeing all the resources
allocated in this function in case of failure.

This problem was found with by the new extra run-time crypto self test.

Reviewed-by: Conor Mcloughlin <conor.mcloughlin@intel.com>
Tested-by: Sergey Portnoy <sergey.portnoy@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/qat_algs.c