Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3123839rwb; Mon, 15 Aug 2022 18:43:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR6BWJGLx5r7gXE2E8QVtt3frwH34Dyl5KMP2+rygXH1FNKsP2MopfPptTYQqBmZSCES62hJ X-Received: by 2002:a17:906:dc92:b0:731:5a2f:6542 with SMTP id cs18-20020a170906dc9200b007315a2f6542mr12361443ejc.441.1660614186756; Mon, 15 Aug 2022 18:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660614186; cv=none; d=google.com; s=arc-20160816; b=zvs07RaWB1/vWMHfMtOgk/PrBebkc+12F7lfXUleceSzSeVwIYgtYOpOZdDA10XSRk cJ7eChQWInVrgKUat6RHv46B8bF4ZRkLClNoK24I7Im5sBILI8sI0clXPHz9bjpxoDhy j8n7nWfxFf6IEqcBYRikJhRudhae/N7Yx/SGcvg5PM1il4K7zPfqXCfC0S6RgZq+rpbc 7srYgg91rWgJ50UvKuk/mujqlhTw33/HFVCBrO+ZUsJ24lcVEbtNzd4AVhvoVK2ZdMsd ERzJ+x9n0/AY9D+xYfYSfwF4aGNHKY2NOtHsUW+ToubenOcbWnZYNTUM7wqtoe9i234N c5ng== 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=QH6lziFUlIkKZ8GvzjXhETAw4Vlq9Tbq2w2SNJPXWic=; b=xzDeN2YMORBH19ujpcMcYsT4GOLwi7P5x++wQC5wzwNXWHpjEqU06ak9pDhzdZVkxg OBwQ5f++8WBuQTBfIyn2WEf80zFswSyg7yE9jBGoX0vlFRJ2zYeMBRhPppLQNIWkwO/5 +ZRLAq8603nau/YuJg4p4F0WvbVZHD6URAXFNJTrBQt2tukTBQgNe/vUZ/hZWGmJ7+cm h2uZpMwKixSJYd5woPOShjgt3+OUSCE/0mprmY3F34YJJYAVFGG9MkBtCstTgQAJKt9a RRrwR9NsQ+ea4SO1fUJxr6lsaW4TSZe43nVQ1KQQiXkL+Xt7NV/5kXo2lI65H7aotouK 5AFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X3tn1MUm; 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 g6-20020aa7d1c6000000b0043d35059c65si8561584edp.160.2022.08.15.18.42.41; Mon, 15 Aug 2022 18:43:06 -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=X3tn1MUm; 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 S1344985AbiHOX35 (ORCPT + 99 others); Mon, 15 Aug 2022 19:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244480AbiHOXYK (ORCPT ); Mon, 15 Aug 2022 19:24:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F61A7FE5E; Mon, 15 Aug 2022 13:05:47 -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 sin.source.kernel.org (Postfix) with ESMTPS id CC268CE12E9; Mon, 15 Aug 2022 20:05:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6687CC433C1; Mon, 15 Aug 2022 20:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593944; bh=XHiBzFvb+eLbGtcLFq0MqwzvtpGwgrJ2dHXZcprAbDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X3tn1MUmCVOh9uKvRvzyGwhTqweiJr3cY7SYsO/BWiLA3vphmrZh8lGdP1EM+tfKC DK5DZnYw4BPmOoiq4IlsebEqnQe+5wrfn13ptrVBoywG+6EHqsDyUkLw+K6xF9gG7h dZjpYeBYNtp1Y9ePDJsa8D2hMQnvK1fKAY4l0ANo= 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.19 0352/1157] crypto: sun8i-ss - fix error codes in allocate_flows() Date: Mon, 15 Aug 2022 19:55:08 +0200 Message-Id: <20220815180453.799055997@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 98593a0cff69..ac2329e2b0e5 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c @@ -528,25 +528,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, MAX_PAD_SIZE, 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