Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2927974rwb; Mon, 15 Aug 2022 14:13:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR59YDe8W2JbzTuV3dDWK+ywfFGu3vs91hA281gY5mwnV2KcMylWH8WhNAFSNAyglwQnx0HS X-Received: by 2002:a17:907:7634:b0:730:c378:b86e with SMTP id jy20-20020a170907763400b00730c378b86emr11448378ejc.647.1660598008426; Mon, 15 Aug 2022 14:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598008; cv=none; d=google.com; s=arc-20160816; b=BH4PhR/0jNB5iEuAcB9fLmU8viGfc+B5S+YLm60IXRwEJWq7Dd8KIcQfQfd6IsKdeK qrHGRrxsBzEWHtbpgnF4MBaKHGUPZqZ04hHtnM4pnZ0XpDwxqnOh4ZOdNZHjbwDAZiu4 /oZCrxv4rsVlWl+ciJYtSH7Mo8nIrYC6pQCzXr6GXzZa09a2UGEdtuEAHbTyN+d906qd c0zFRCZlXcDukr6p1Q5qYYJzgn8C4zhtEVffrWPXC5OEb2bq41fSPPH0h3OUrVKScOMd TRJTr+ykvIq2tmXVBJLiGnxxd0957c5bzJz/TZNeqoyzxfDX2FmJchhv4kO56IAwoW8p H0Uw== 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=pHxYxQga5nbC5tH8R/c3ihunRh6Vwso4dIYt+Yw3KEj0LNuXdupHbjnvlw7Zu+rduf BxwCp+M78/sxEhEABF19fMf5k/tom6UMBlRJSrUZAQQiyaEHGY9U5fujE58Gkl5jMB7Q 855RsHMC9d5tSJLPdmbyY3Bqw+S9jaJFAoOp9eAk/6vWdskXKInQYJhZR1OLK4gQ7Nws pz9jYvO1Nb+rOkjkqHmGV1kyDT01s1rxzCReKuomJkmgheL/QEDEmf/cqBttlOjd/xRA hDMPnF8yao9hmKSmfsD4tKLOs0mT3CvwO0V2E60igKiwkgfeGABj+ySa9ncPoiephT6a XV1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wfOGI8xT; 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 mp31-20020a1709071b1f00b0070397358bcbsi8537826ejc.33.2022.08.15.14.13.01; Mon, 15 Aug 2022 14:13:28 -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=wfOGI8xT; 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 S244479AbiHOSvS (ORCPT + 99 others); Mon, 15 Aug 2022 14:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244116AbiHOSqe (ORCPT ); Mon, 15 Aug 2022 14:46:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48FFA40BD6; Mon, 15 Aug 2022 11:28: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 dfw.source.kernel.org (Postfix) with ESMTPS id 79D8460FEE; Mon, 15 Aug 2022 18:28:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63BEEC433C1; Mon, 15 Aug 2022 18:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588089; bh=KH+LbbLmVGf4w93XlXej3XCKb8SjTDmLrLAJpeWu4S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfOGI8xTpfZyfD7pDdgREuYahR2W+cAuKjFIYW8GMUx/bp1DYhmHXeaH71whnR9Pa jBCw9oxnWlLg30qqV0fc7HeIlI2nuI8BlXNuoQyddMC4Wpve0tB9oyaEnpxqHb5xRM woTHdaV5qNMvmMI0YCQp0zFKJlUwY2nrxmCFKVOs= 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.15 260/779] crypto: sun8i-ss - fix error codes in allocate_flows() Date: Mon, 15 Aug 2022 19:58:24 +0200 Message-Id: <20220815180348.460484140@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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