Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Catalin Vasile <cata.vasile@nxp.com>
To: <linux-crypto@vger.kernel.org>
Cc: <linux-crypto-owner@vger.kernel.org>, <horia.geanta@nxp.com>,
	<alexandru.porosanu@nxp.com>, <scott.wood@nxp.com>,
	Catalin Vasile <cata.vasile@nxp.com>
Subject: [PATCH] crypto: caam: fix caam_jr_alloc() ret code
Date: Fri, 6 May 2016 16:18:53 +0300	[thread overview]
Message-ID: <1462540733-2170-2-git-send-email-cata.vasile@nxp.com> (raw)
In-Reply-To: <1462540733-2170-1-git-send-email-cata.vasile@nxp.com>

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>
---
 drivers/crypto/caam/jr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 6fd63a6..5ef4be2 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -248,7 +248,7 @@ static void caam_jr_dequeue(unsigned long devarg)
 struct device *caam_jr_alloc(void)
 {
 	struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL;
-	struct device *dev = NULL;
+	struct device *dev = ERR_PTR(-ENODEV);
 	int min_tfm_cnt	= INT_MAX;
 	int tfm_cnt;
 
-- 
1.8.3.1

  reply	other threads:[~2016-05-06 13:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06 13:18 [PATCH] crypto: caam: add backlogging support Catalin Vasile
2016-05-06 13:18 ` Catalin Vasile [this message]
2016-05-10  9:54   ` [PATCH] crypto: caam: fix caam_jr_alloc() ret code Herbert Xu
2016-05-09 14:50 ` [PATCH] crypto: caam: add backlogging support Horia Ioan Geanta Neag
2016-05-10 14:59   ` Alexandru Porosanu
2016-05-10  9:46 ` Herbert Xu
2016-05-11  7:53   ` Catalin Vasile
2016-05-11 10:54     ` Herbert Xu
2016-05-13 12:55       ` Catalin Vasile
2016-05-13 13:50         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462540733-2170-2-git-send-email-cata.vasile@nxp.com \
    --to=cata.vasile@nxp.com \
    --cc=alexandru.porosanu@nxp.com \
    --cc=horia.geanta@nxp.com \
    --cc=linux-crypto-owner@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=scott.wood@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox