Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2201226iof; Tue, 7 Jun 2022 23:02:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7GCGfxFvZykdNQaqi7dULJTmZQkeq2WZb3O8H4FJiY5khSPwjthhyuRcKHbKdKEYGtAic X-Received: by 2002:a17:902:d2ce:b0:167:7637:7025 with SMTP id n14-20020a170902d2ce00b0016776377025mr15563477plc.37.1654668178062; Tue, 07 Jun 2022 23:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668178; cv=none; d=google.com; s=arc-20160816; b=OHFAZTaWG12FF+/ttfqC4w/Md541Q83o9Qc+/aD91DXI76Jir53b5ZcXs/oLkoA32m PNcazcVz0eAC/r1xP1Yjz3cZOysqEXxy9MjhvAqu2CFf0zEQ/i4SQLY5I1hcwlOFSGBz 00AYqd8YrgZDUBaa45SA9u8HUQTm1GX2iLlu2YEQo39V6qmlHoJhjo8OKcmGBLT28oOR NgbWtdiAZv3qkSDl3g9Cu3mIXrYzT4Dff1ejh0lFo8u9FBH/bdKWlamCOXAYSb4kOHx6 xxtwTIKrPJUTRg6kpHdceNYCoS6Rspdls0C1FMDMmk0zhSko9sSqMDHHhiDWMA8jqwPs wK2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0md+eY6GBjcgHoUnk7sipJPZOpH0dKOBck6Yy8Fqo34=; b=EpjC/vHPth942x6sCZVKS3BIKgTeHpIbrB2OnWPI+D4mBJxQf13Qpz3Hk6ywWzQv/d On3SaAu8OuyVAC7OlWTmknGHlKxIx3LFc4diZZMU0OozK8i1csinhSE+ihquMXajvFJ8 8WinvL6a5Hnr9Ty7Q3XG6eMznSXR9jSUGmeBgd/pbU3HWVOEDWBh5tsJ9NDNiPPj90iq n9SvY+8+Jetp/uEUCTlyxU2VXTgumlDnRxjmk/SOvBd1/zw6fFRRJBVBW4d5ZPHZA1NK yka7GAk+3geWMwdnwh7OoSPWlTb/A0U96BcHzh6CfsXZFtYFheZSTKqszES2kLIoNlvr 5Gxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1hXDS0XZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w189-20020a6382c6000000b003fe343c511esi1446579pgd.789.2022.06.07.23.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:02:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1hXDS0XZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5211443BE4F; Tue, 7 Jun 2022 22:27:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376816AbiFHBZK (ORCPT + 99 others); Tue, 7 Jun 2022 21:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382833AbiFGV7T (ORCPT ); Tue, 7 Jun 2022 17:59:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4B5F24DBEC; Tue, 7 Jun 2022 12:14:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1CCC8B823AE; Tue, 7 Jun 2022 19:14:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B308C385A2; Tue, 7 Jun 2022 19:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629249; bh=gdWMOUDKVAqi6yCejsLZGzwhdUsyVmA79NthQ2UU4Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1hXDS0XZ6Nv74LxMFe6dEB8MrOOxKZBqFNeO6H0GgMZO7DoQjI5YgwKgbOtcC0cbi NG1QSrAKRvyPNVijcztICrHjCt8CFcWwOyo0PepWA7XIKtIz4NYHG82+q1/ZWEwssm pFAyRvltNxju/9tdT5BQDXFbtx3ExsrT+cmbD99I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Corentin Labbe , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 622/879] crypto: sun8i-ss - handle zero sized sg Date: Tue, 7 Jun 2022 19:02:20 +0200 Message-Id: <20220607165020.906083360@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corentin Labbe [ Upstream commit c149e4763d28bb4c0e5daae8a59f2c74e889f407 ] sun8i-ss does not handle well the possible zero sized sg. Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms") Signed-off-by: Corentin Labbe Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c index 1a71ed49d233..ca4f280af35d 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c @@ -380,13 +380,21 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) } len = areq->nbytes; - for_each_sg(areq->src, sg, nr_sgs, i) { + sg = areq->src; + i = 0; + while (len > 0 && sg) { + if (sg_dma_len(sg) == 0) { + sg = sg_next(sg); + continue; + } rctx->t_src[i].addr = sg_dma_address(sg); todo = min(len, sg_dma_len(sg)); rctx->t_src[i].len = todo / 4; len -= todo; rctx->t_dst[i].addr = addr_res; rctx->t_dst[i].len = digestsize / 4; + sg = sg_next(sg); + i++; } if (len > 0) { dev_err(ss->dev, "remaining len %d\n", len); -- 2.35.1