From patchwork Thu Apr 13 12:14:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9679321 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7D2F60383 for ; Thu, 13 Apr 2017 12:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A923928654 for ; Thu, 13 Apr 2017 12:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D80B2865A; Thu, 13 Apr 2017 12:16:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 682BE28654 for ; Thu, 13 Apr 2017 12:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753567AbdDMMOl (ORCPT ); Thu, 13 Apr 2017 08:14:41 -0400 Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:58145 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753426AbdDMMOk (ORCPT ); Thu, 13 Apr 2017 08:14:40 -0400 Received: from localhost.localdomain ([92.140.232.30]) by mwinf5d75 with ME id 7oET1v00B0g0jYk03oETL6; Thu, 13 Apr 2017 14:14:28 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 13 Apr 2017 14:14:28 +0200 X-ME-IP: 92.140.232.30 From: Christophe JAILLET To: herbert@gondor.apana.org.au, davem@davemloft.net, harsh@chelsio.com, hariprasad@chelsio.com Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/2] crypto: chcr - Fix error checking Date: Thu, 13 Apr 2017 14:14:30 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If 'chcr_alloc_shash()' a few lines above fails, 'base_hash' can be an error pointer when we 'goto out'. So checking for NULL here is not enough because it is likely that 'chcr_free_shash' will crash if we pass an error pointer. Signed-off-by: Christophe JAILLET --- Another solution, amybe safer, would be to instrument 'chcr_free_shash' or 'crypto_free_shash' to accept an error pointer and return immediatelly in such a case. --- drivers/crypto/chelsio/chcr_algo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c index f19590ac8775..41750b97f43c 100644 --- a/drivers/crypto/chelsio/chcr_algo.c +++ b/drivers/crypto/chelsio/chcr_algo.c @@ -2351,7 +2351,7 @@ static int chcr_authenc_setkey(struct crypto_aead *authenc, const u8 *key, } out: aeadctx->enckey_len = 0; - if (base_hash) + if (!IS_ERR_OR_NULL(base_hash)) chcr_free_shash(base_hash); return -EINVAL; }