From patchwork Sun Jan 7 12:14:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 123658 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1548447qgn; Sun, 7 Jan 2018 04:18:02 -0800 (PST) X-Google-Smtp-Source: ACJfBosJmyDrvGwAy+STWx8tgHzVS3ATk8thaXBDEi6IvSPDAziVy3pObkRjIY5Ay9/Lb5wRyZ8j X-Received: by 10.159.244.5 with SMTP id x5mr9054174plr.257.1515327482177; Sun, 07 Jan 2018 04:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515327482; cv=none; d=google.com; s=arc-20160816; b=QFsiM5Nhb7LkACoYGkoEoEjzDC7/pq+4Ae+scPByZ/uh49OcT88txDQnVP0BlliYMZ ZBlEkpopWcAPNd3ninuowU3nSybFOJkgE/0mPLxgcoXF8HIs0ylUmrYdi1ryit4KqDhr z9Sj7L4WGGhAGPHI9ZMV6PH9i7Es2/jDYNRWEwbcP45kbRRArI01PKBlcKd3kzJjA3u0 rC3SdH70qNwEnv2iiNjnR1MfIfJ5nsxtl4MZBC+l/twli7qlrrcj9KSWRX0/c3SEo/Wn i7zlHzd+CelnMaRXb72eMwL25NNBLLvg2vTkrOmLvMdQJOmLOczc+c1u3XwyUwn/BZXm BRQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=64gfPsS5jAnlTbTnv5k/pBhSLLk4MjLz6hCgGoVVTyk=; b=g+n1ZrjB/pvsfKfvEdxlLrLEzhy/5QidDrMtMJTCllXzdPFCSYfQmaKcyFX7XZbTgZ ft/c8Hant+lO6anW5mgQo6Atqb7kFmaRtwiiQqmQWG1yoPt/jb8l93op87SAq4/YroJE drXkXox125fE0aH2jruYcvrHk1cgPNbp4J4fnyN7leiKFWhgWXyJM5y/DUm76Nr6Tj+a /E8OxWOxJDbDo+w81wHlbtHNWvHAX48CfOFkz+yfCNsa0bnIY653YJN4PhwZHqmJ+qJ+ DR5JL3b5TQc4h/59VQPWmuID1GBr/4rXIQ0uvDltK2v1F5xs0YrvijOg2nRguoUotCU6 Db8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si6930673pld.709.2018.01.07.04.18.01; Sun, 07 Jan 2018 04:18:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753777AbeAGMSA (ORCPT + 1 other); Sun, 7 Jan 2018 07:18:00 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57534 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752852AbeAGMR7 (ORCPT ); Sun, 7 Jan 2018 07:17:59 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25A0F1435; Sun, 7 Jan 2018 04:17:59 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 152933F581; Sun, 7 Jan 2018 04:17:56 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org Subject: [PATCH v3 14/27] staging: ccree: handle end of sg list gracefully Date: Sun, 7 Jan 2018 12:14:25 +0000 Message-Id: <1515327285-8948-15-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515327285-8948-1-git-send-email-gilad@benyossef.com> References: <1515327285-8948-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org If we are asked for number of entries of an offset bigger than the sg list we should not crash. Cc: stable@vger.kernel.org Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 78288ed..0f71264 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -94,7 +94,7 @@ static unsigned int cc_get_sgl_nents(struct device *dev, { unsigned int nents = 0; - while (nbytes) { + while (nbytes && sg_list) { if (sg_list->length) { nents++; /* get the number of bytes in the last entry */