From patchwork Sat Oct 26 14:52:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 11213537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F26111951 for ; Sat, 26 Oct 2019 14:54:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6D3E2070B for ; Sat, 26 Oct 2019 14:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572101642; bh=SmDraQe5IZLOG+WLxMhmI/EhoYeINysU8csTg6xa8F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=b1TOpKFyIeD4dreujw3+DBo/m4nfFe0ROExOHyh0GeZ8SsMNeil8NLr1MzqWecP8w UNdVBZS1Uei7+Xdzc2zRSDcF9cUOxRf8SQB6lmtfVoRGcsmvoG0dM0nsaO5jOezWr3 Bk1tGjo+QHh1Sfp3km0/5AeFyYEzi0NWDCVv+Hpw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726257AbfJZOxy (ORCPT ); Sat, 26 Oct 2019 10:53:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfJZOxy (ORCPT ); Sat, 26 Oct 2019 10:53:54 -0400 Received: from e123331-lin.home (lfbn-mar-1-643-104.w90-118.abo.wanadoo.fr [90.118.215.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABDB92070B; Sat, 26 Oct 2019 14:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572101634; bh=SmDraQe5IZLOG+WLxMhmI/EhoYeINysU8csTg6xa8F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xcZ3QJDuPTu5jFBkBWRXTkOUoHLsDsflyjB+t4Tf2Pvx+x3kKyMX1HDiNdUudjAYx r1+vibniNvBkRxcUiHQYaNTOVhd2PnOI+UbF0IQ5WP10C/2xivvAOyzypFvf1qVggE fkjZyrqwzn7oenlDWxG+8onGKC5Aiyw/UMoB0ckU= From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, Ard Biesheuvel , linux-omap@vger.kernel.org, Tero Kristo Subject: [PATCH 3/6] crypto: omap-aes-gcm - deal with memory allocation failure Date: Sat, 26 Oct 2019 16:52:56 +0200 Message-Id: <20191026145259.16040-4-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026145259.16040-1-ardb@kernel.org> References: <20191026145259.16040-1-ardb@kernel.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The OMAP gcm(aes) driver invokes omap_crypto_align_sg() without dealing with the errors it may return, resulting in a crash if the routine fails in a __get_free_pages(GFP_ATOMIC) call. So bail and return the error rather than limping on if one occurs. Signed-off-by: Ard Biesheuvel --- drivers/crypto/omap-aes-gcm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index dfd4d1cac421..05d2fe78b105 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -120,6 +120,8 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, OMAP_CRYPTO_FORCE_SINGLE_ENTRY, FLAGS_ASSOC_DATA_ST_SHIFT, &dd->flags); + if (ret) + return ret; } if (cryptlen) { @@ -132,6 +134,8 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, OMAP_CRYPTO_FORCE_SINGLE_ENTRY, FLAGS_IN_DATA_ST_SHIFT, &dd->flags); + if (ret) + return ret; } dd->in_sg = dd->in_sgl;