Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751641AbeAAMJs (ORCPT + 1 other); Mon, 1 Jan 2018 07:09:48 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59174 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751616AbeAAMJq (ORCPT ); Mon, 1 Jan 2018 07:09:46 -0500 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 14/26] staging: ccree: handle end of sg list gracefully Date: Mon, 1 Jan 2018 12:06:41 +0000 Message-Id: <1514808421-21993-15-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514808421-21993-1-git-send-email-gilad@benyossef.com> References: <1514808421-21993-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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(-) diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 33b9709..cb3e235 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 */ -- 2.7.4