Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2929756rwb; Mon, 15 Aug 2022 14:15:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5TJSp9DVWXZBkSTM6ERYKNPupF8O2qXgFcRAgZLRinI3hY5TthFQkxT8eu33hKzXR3Vkt8 X-Received: by 2002:a17:902:e84d:b0:16d:c9a0:e502 with SMTP id t13-20020a170902e84d00b0016dc9a0e502mr18770734plg.125.1660598050078; Mon, 15 Aug 2022 14:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598050; cv=none; d=google.com; s=arc-20160816; b=0KpvUKRcI/lN9En+OWTU3/wNrPgLVV9XJW5mGK0hAD0Y9ktgLyr6Pjd6UGfamWmmfq Qb5g6S0flzNKcEzOLC90VuvUU8odgrgPPKsrn007rSh3datiA3BBwm+u9tb70wEESq2U Ur4h5+CBrHOJBg7B2qIAek+26TWIe+bQj+6yfn2mijP2zgfbdMAbnn/7Sqj9AeN5L/cH bJyDtQhXaFZHgzl81VSm/zBWLl0jiPkbnAlTCvGEUGzDVaH1Mdxu+y408EScoxCnsLPl kRIAraOtBxdueJJDaUBln3iR4rkiG5xZtSF9hdTsPNZy7Lc+pwAMnFzlEb+7nPzYOYDg mZWg== 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=KYFxrV3oxTdHjeE1TfWMiwr5yYZcjtUsyTWvZW/RgYE=; b=EQTyJujLPUywKsgI7s+pjMd6+Frd9fejfx+WpplpFQYKKfnmsCieQLfIexTxth+kpS HwYi46B8YIzTX3Pa/nMxDyUrnp9dOucJutnND1TNnNH/9bLkzZ9aBnM7iYHLgsiPKgCC txIc+OZFKk/hL8aGkBSdY7y3oQcaKOJVRpX17LIJHDfsYvKjThijz6laAJb9DPDDM8Xr 9xvlO+PPCUjgqFdgt5FJJoI5xUV2GrLSRUf8rkdikPxtQf7N3Cbj6XBojCSQZTJNjg/R SbHnHzPZyjr/HOlh0j4TpuC7ScJ9TPqvpU3sOPOLvG5WisHAPjVoOoUZ6ESsPtF2iolj o0hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vqn3L++T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a170902bd8200b0016c323e8151si10802440pls.214.2022.08.15.14.13.58; Mon, 15 Aug 2022 14:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vqn3L++T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243333AbiHOVAU (ORCPT + 99 others); Mon, 15 Aug 2022 17:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243880AbiHOU7e (ORCPT ); Mon, 15 Aug 2022 16:59:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74EFBC2EAD; Mon, 15 Aug 2022 12:12:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A8ADF6009B; Mon, 15 Aug 2022 19:12:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95999C433D6; Mon, 15 Aug 2022 19:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590768; bh=KH+LbbLmVGf4w93XlXej3XCKb8SjTDmLrLAJpeWu4S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vqn3L++T/WtGd+TbQItxjrIt+ZOJJ7rhMJAsLRkKxHD7ZLgRJ6nlwXx0T/kwokJdB O3YE+hapKAWYUo20PayOPq2thrHSWVkRKMb5fnGcg/6qAnaq2lFDUfx0upKhSa/HG3 CR7w+FG7EtKiumvRO+aASI3RXS35WZq463jGFm/8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Corentin Labbe , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 0334/1095] crypto: sun8i-ss - fix error codes in allocate_flows() Date: Mon, 15 Aug 2022 19:55:33 +0200 Message-Id: <20220815180443.623676001@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Dan Carpenter [ Upstream commit d2765e1b9ac4b2d5a5d5bf17f468c9b3566c3770 ] These failure paths should return -ENOMEM. Currently they return success. Fixes: 359e893e8af4 ("crypto: sun8i-ss - rework handling of IV") Fixes: 8eec4563f152 ("crypto: sun8i-ss - do not allocate memory when handling hash requests") Signed-off-by: Dan Carpenter Acked-by: Corentin Labbe Tested-by: Corentin Labbe Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- .../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c index 786b6f5cf300..47b5828e35c3 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c @@ -476,25 +476,33 @@ static int allocate_flows(struct sun8i_ss_dev *ss) ss->flows[i].biv = devm_kmalloc(ss->dev, AES_BLOCK_SIZE, GFP_KERNEL | GFP_DMA); - if (!ss->flows[i].biv) + if (!ss->flows[i].biv) { + err = -ENOMEM; goto error_engine; + } for (j = 0; j < MAX_SG; j++) { ss->flows[i].iv[j] = devm_kmalloc(ss->dev, AES_BLOCK_SIZE, GFP_KERNEL | GFP_DMA); - if (!ss->flows[i].iv[j]) + if (!ss->flows[i].iv[j]) { + err = -ENOMEM; goto error_engine; + } } /* the padding could be up to two block. */ ss->flows[i].pad = devm_kmalloc(ss->dev, SHA256_BLOCK_SIZE * 2, GFP_KERNEL | GFP_DMA); - if (!ss->flows[i].pad) + if (!ss->flows[i].pad) { + err = -ENOMEM; goto error_engine; + } ss->flows[i].result = devm_kmalloc(ss->dev, SHA256_DIGEST_SIZE, GFP_KERNEL | GFP_DMA); - if (!ss->flows[i].result) + if (!ss->flows[i].result) { + err = -ENOMEM; goto error_engine; + } ss->flows[i].engine = crypto_engine_alloc_init(ss->dev, true); if (!ss->flows[i].engine) { -- 2.35.1