crypto: caam - fix caam_jr_alloc() ret code
authorCatalin Vasile <cata.vasile@nxp.com>
Fri, 6 May 2016 13:18:53 +0000 (16:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Jun 2016 19:15:49 +0000 (12:15 -0700)
commitfd97b4fbaaf2fa1776de2cd73d9ec9d3ce82e68c
tree169802994fb9c3e9ada7c3b3b894f757a4fdf92e
parentf199023137853eb1d46e8b7ebc274b29ba99028c
crypto: caam - fix caam_jr_alloc() ret code

commit e930c765ca5c6b039cd22ebfb4504ea7b5dab43d upstream.

caam_jr_alloc() used to return NULL if a JR device could not be
allocated for a session. In turn, every user of this function used
IS_ERR() function to verify if anything went wrong, which does NOT look
for NULL values. This made the kernel crash if the sanity check failed,
because the driver continued to think it had allocated a valid JR dev
instance to the session and at some point it tries to do a caam_jr_free()
on a NULL JR dev pointer.
This patch is a fix for this issue.

Signed-off-by: Catalin Vasile <cata.vasile@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/caam/jr.c