From patchwork Fri May 6 13:18:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Vasile X-Patchwork-Id: 9033461 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 993E29F30C for ; Fri, 6 May 2016 13:51:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0EDD20373 for ; Fri, 6 May 2016 13:51:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC60820328 for ; Fri, 6 May 2016 13:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757430AbcEFNvI (ORCPT ); Fri, 6 May 2016 09:51:08 -0400 Received: from mail-by2on0071.outbound.protection.outlook.com ([207.46.100.71]:60288 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756585AbcEFNvH (ORCPT ); Fri, 6 May 2016 09:51:07 -0400 X-Greylist: delayed 1075 seconds by postgrey-1.27 at vger.kernel.org; Fri, 06 May 2016 09:51:06 EDT Received: from BN3PR0301CA0007.namprd03.prod.outlook.com (10.160.180.145) by BN1PR0301MB0706.namprd03.prod.outlook.com (10.160.78.13) with Microsoft SMTP Server (TLS) id 15.1.492.11; Fri, 6 May 2016 13:19:01 +0000 Received: from BN1AFFO11FD045.protection.gbl (2a01:111:f400:7c10::167) by BN3PR0301CA0007.outlook.office365.com (2a01:111:e400:4000::17) with Microsoft SMTP Server (TLS) id 15.1.492.11 via Frontend Transport; Fri, 6 May 2016 13:19:01 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD045.mail.protection.outlook.com (10.58.53.60) with Microsoft SMTP Server (TLS) id 15.1.485.4 via Frontend Transport; Fri, 6 May 2016 13:19:01 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u46DIujn029807; Fri, 6 May 2016 06:18:58 -0700 From: Catalin Vasile To: CC: , , , , Catalin Vasile Subject: [PATCH] crypto: caam: fix caam_jr_alloc() ret code Date: Fri, 6 May 2016 16:18:53 +0300 Message-ID: <1462540733-2170-2-git-send-email-cata.vasile@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1462540733-2170-1-git-send-email-cata.vasile@nxp.com> References: <1462540733-2170-1-git-send-email-cata.vasile@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131070143418371908; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(106466001)(87936001)(105606002)(47776003)(11100500001)(19580405001)(19580395003)(36756003)(4326007)(33646002)(2906002)(1220700001)(50986999)(2351001)(76176999)(5003940100001)(81166005)(229853001)(586003)(50226002)(2950100001)(92566002)(8936002)(86362001)(5008740100001)(50466002)(85426001)(104016004)(6806005)(110136002)(48376002)(189998001)(77096005)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0706; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD045; 1:NwXeMRL7X6nNejav8WEBYGFD5RkW6E4Ewk8C6VUSxBUaxakdXwBS41GZtyl8eQ8NhvZav7aUHDymurLD3h4PRGuGOmu+PyzvQjdWjVdkgiFzF9ez0MQNC4EsbYpVhTNOoMn/7yxd9Um28tFZ/o4QG3Ize5Mtf3RV4xG0cskPgZSwgEmPJ6xHaBPJQcc/aPgcUCJIgy4n7qrx6jGsMbMYSz/AcZ90PvJIBegGsP2QMG/75/bW4jApvmUzP9hsupCi3YgpcleB3Ytuo3iutSXS9pyyuVQoavx8Siy+uJsDjIDGEvhl91Muu0C9jLJdOiH8F5vqBYovgLkmwHQVP+6aA1Wim0dJ28xor2w3yNn1Wh7Vlc+dGJ/i2/SXb3Ikd3lI5J9uTk5nsbig+bwWgJFT229c//e+Bjg7gDk9Oail5oSOsopzehhnLGVVk37mclwFEALifZ6nP6Ql40g5MXCbtQD43XZzNIYPzHSmsuvbZnZ93cqCCTIXQqvA5QUCU9bZUCvnIc4nfXYwIke/gvcXaX1zs4h62HE2tVzG5AY3t6KTa6aRo1wRTnY698uuE1ZaOBHvyAms9WrinJ1h9eA9s8+ykVrRwtMd6Blld1jfH6iS5wS/yE91/mjspRFE/1r7KTQm/TlPOA6wFH1FvYS5J1B9lYT5dMfa96Svz71Xl1qDnINJi88CUc3yIBmB9NEgzCf0yijjdDiqI55WKR1tyw== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0afeca6e-2fd8-4cc3-2de6-08d375b0fd91 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0706; 2:nRuhldFwUIYW7bWk9CWg4G2jzuvBDmaYM6wwQI7pctlKAw25RdSxS3ym2JA5mwDJt4UODmZc+pUWjkM8HZ35fUCy4gAO3icMXWDN/KwTtqzyZH+gJG7YUOZN3lYleAorLPmVGRvmKWVKn4TGMojbGOiagAHe9FuxesZ0eOtAz89vaymHrVKNPa6DgvrZsDSg; 3:136Q/KENE5p2CE508sLuyNovH757B170Q/rY5pSJR+39ltdcqrE/wL7eZpVNrzY8lQLWxviufyO2uH/4Sq8TvMou8GXeFu1zFrPO3ogdn5jSRxmI796vqrn+VuIMBAHgiFKNCIYevkzqjmtH4PHErHnwJAYQGSFnba3fOyhgVV93gfpNFLBs9/HFdGpGe4yo3yjWSjdv46HE95GKBYFKr+T57QxFGT8rpOOPDYuVlvo=; 25:0Wq5oFqe7VbeeVV0u4QRqtwvj5jfc63NqnI3LOVW4CFDOxyaJVhVArho9vAWF2Q6nyZw50YlXfuYDn77c2mvRuuVU32PxMmP9iVHux8mMeQ2mpLmQOJVHREY9CMMChxIVpLHS8q2cKbMCcQjs8sCdV4kcYFqK4/ucmqwguVDKIKaReZUHthwcLrojV1jagxB5vybzWqVxcZZrKa4rnqr8RZbOFXnX9VJjgGmDxmkF59srKc7wDaBgJId5ZdsJWpZVsVvp5SZ7qqxd4iFChqFkVtB5DlLUpZ6LHJMAv2hkYlJOOuAcUljws4dcZpowYogYKEwXOdFMK9ujs8D6xnLdWkwQs7WarsoSQ2tkimDA7euk5Ha6oofzwb2m0MEpJbQJGat+zuv4fXYC5BD39ngfdE28Y1ghHcEwq4NiLHhFd2pMn4/KJciyl6Medjn2mtX X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0706; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13017025)(13015025)(13023025)(13024025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BN1PR0301MB0706; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0706; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0706; 4:HNYsKt3iezsMeeT0d2Rt2AVgopAZ+oNc3swwKUZFcwwEcJp+9SMHLPLV3Mx6PHExOqLR0uuvp+Dcu1AiYQwXN2SqhMLCw4v7vryvHIQ+Zs12Bi564t+CeXU0LCONbCNoBef11ta/9Ks7cFcEHmjjupXJ1CpxTIO7aSrRLFxN74OtnnBaljIKb+7w85O9eekYy5QAbmDBXUtVGGQ2gh0gfqynA2jfZI74SAhH65lz2GESMqdosD5j0pnoPsjlvQV6DA/KT+TqHH38h0P6pYxXHaA/9dwe+c/CmiLSSU1TWcspKXtUV5j0GBvNrDMJ7qCaHJDw+lNgF/tQnjQIjg1dWz9AhDHlg8sHasIeDQbErm63moe6EJ1jzAbZpE3ZbCNZR2kRsQTWIXNkljMRwAjVwOdv5QTyYqK4i0lovsvh2mB/GlEoh7Maz5c7i43E/sWxXeJI3fBh53y7RfysCkF2FRrv7eyYButXnmZEC705QR0= X-Forefront-PRVS: 09347618C4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0706; 23:pUnfhT2WJIveC/t1mLi7iOVfwHCae5KcZLC+97w?= =?us-ascii?Q?QM8C5X25ODqkR6aMmQKhbjBT50zj4OtuQEwxtjQNpyjBXad92GL1HI1N/830?= =?us-ascii?Q?W6lIDwBbIJYK5kkJA3UAbK0eEkpVFI6ZAP/CHQnmXZFqhQXavolVeBpZteW2?= =?us-ascii?Q?dl2j4umf7rwTz5ptnTjg/9hTg43cDZMGFtw/6KOBwJh6OwW1NVjYPGQEQH7d?= =?us-ascii?Q?lzfJEsFrRKQREmRxX4xTpFHzK5nGA+jBCxfHm4/B/UcT6a6dncXyxusO1S3n?= =?us-ascii?Q?3vdA3eOEUgZ1n7x7udjLn8XsFlcpQbQaq+BhIFJpSTi9zWOPLkiBh2/4u3Oy?= =?us-ascii?Q?KT3mp0PIutjn4wRegMpoxxOVOdT9xXRFln9n5fhUorvzV6emOnX5/KX3ziLL?= =?us-ascii?Q?QMWXG/Z51POG8WOtDk6GsDD+39vN6Ocvr2F+oLIVldTl0O7sULvazZqSBpMG?= =?us-ascii?Q?+D6HU1bKqFIqrKOsYzgl7Irs0XIPy0Jz16Z+Up7TN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P+jiM=; 7:4wHW5+x+kELmCZmmRp0122UlxDGrslObZGiDKrDvD1N0TeZ9rynBXKfDSV2BI5RscEQuQavv6Ur4pQo2S9+6EvSil5U/kMq6kjSEuR69owpF9gh9w5NBOivdrm9r+9HgCtdl3yo2AzffViQs4NCtAt+9R/1C7Q2kqZFQKS/gZXEuXzaGZC4WXTs3sh1V5XVG SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2016 13:19:01.5875 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0706 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;