From patchwork Wed Nov 4 20:13:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7553061 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 AB99E9F36A for ; Wed, 4 Nov 2015 20:15:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB43120571 for ; Wed, 4 Nov 2015 20:15:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5CE520585 for ; Wed, 4 Nov 2015 20:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030834AbbKDUO4 (ORCPT ); Wed, 4 Nov 2015 15:14:56 -0500 Received: from mail-wi0-f175.google.com ([209.85.212.175]:33830 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030775AbbKDUOy (ORCPT ); Wed, 4 Nov 2015 15:14:54 -0500 Received: by wikq8 with SMTP id q8so99485676wik.1; Wed, 04 Nov 2015 12:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SNY2kEw36A3GcMloMbgB0RCfA9VU4qrswVftOpHUgpc=; b=QUBFYVc4LMi6TnsJLMX9nf2AMn0vZpYUird6lTwNjTmpkjsqt27B+CR3pEiG4b9QBe TAiqgclNS+UuuPrEfddrwkSKGJwtt3nalGwEXyu2S4tK80pchWkh739a0BaGgC1bqHdG o+wK/TK9hBPnNo0Xn/xE82hQIbWyu8Ifd/61CM0Gaycclx02rRGnjarM/ZXBuja9QVYd y3LEHRpb4rbfTPJZLTghKCLRRDZbYZoRkk3MGb61BGY29uJKVucxA/iF1EkWRhuG+wbE IvI/L/p+x2JTA9eezgM/Fta5eKc6/nM+hQglXUCOzzf3/iTFPoDTibmtKGjf/qWwK/ob QhNg== X-Received: by 10.194.235.101 with SMTP id ul5mr4100414wjc.107.1446668092355; Wed, 04 Nov 2015 12:14:52 -0800 (PST) Received: from Red.local (ANice-651-1-289-62.w83-201.abo.wanadoo.fr. [83.201.177.62]) by smtp.googlemail.com with ESMTPSA id 77sm4702051wml.20.2015.11.04.12.14.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Nov 2015 12:14:51 -0800 (PST) From: LABBE Corentin To: clabbe.montjoie@gmail.com, davem@davemloft.net, dmitry.torokhov@gmail.com, fabio.estevam@freescale.com, herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] crypto: amcc: check return value of sg_nents_for_len Date: Wed, 4 Nov 2015 21:13:39 +0100 Message-Id: <1446668045-8620-7-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1446668045-8620-1-git-send-email-clabbe.montjoie@gmail.com> References: <1446668045-8620-1-git-send-email-clabbe.montjoie@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, SORTED_RECIPS, T_DKIM_INVALID, T_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 The sg_nents_for_len() function could fail, this patch add a check for its return value. Signed-off-by: LABBE Corentin --- drivers/crypto/amcc/crypto4xx_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 27288fc..e6f7757 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c @@ -781,6 +781,10 @@ u32 crypto4xx_build_pd(struct crypto_async_request *req, /* figure how many gd is needed */ num_gd = sg_nents_for_len(src, datalen); + if ((int)num_gd < 0) { + dev_err(dev->core_dev->device, "Invalid number of src SG.\n"); + return -EINVAL; + } if (num_gd == 1) num_gd = 0;