From patchwork Fri Feb 24 02:05:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Liu X-Patchwork-Id: 61103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp651169wrd; Thu, 23 Feb 2023 18:06:22 -0800 (PST) X-Google-Smtp-Source: AK7set+aG77fQI70It1DZg0WN8rtUscB/2GE3HuY8NPx8I0rPn3ast1lB3U4vb1rxZfndFlVXgJk X-Received: by 2002:a05:6a21:6d81:b0:cb:c276:58bb with SMTP id wl1-20020a056a216d8100b000cbc27658bbmr10069026pzb.4.1677204381900; Thu, 23 Feb 2023 18:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677204381; cv=none; d=google.com; s=arc-20160816; b=ObVwQ524scJDOkbcPqqjwf6pLZf//+bSiT58BodU8wY92KnhkUDneaD6RwVkvbEHEo 9JBSmzxgXSkIiR3T4A3d1YutZBxN623gR4MWQoVn901pntd3n4hn4JrapwpWdrdHj/3m /3cTLkrasxTS2H5Vm83QyivMplOL3lqzh62mDladw6vNbg8wd2KHLhwaoC3U3gMSLfJ1 BhnMcT1oiLUHmnb+M0LSmKBOK/LIq6ugzTFe92kf648km/I9nYxJ/9FDmGw6Q4+qrL6b JjMiRf4wpy0nudEk/QXF9UZ7pUnlPUGswEQWP0m8DXWq2ys7BpWIvTlzEuarFMWURUAO ZsPQ== 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 :message-id:date:subject:cc:to:from; bh=Q/sdchvZPKQHtdG6EeMgsRtDCjc6+PX/cyhIUbGD584=; b=C7BCWSqeMYa9CauspFhfd8B3SLG7tlMtVzhs3QVC5WQgU0IFmTp0ogn6TjVVnCqMo+ r5ciYvst3bnfpbXiOnsRhl6ijVAsVEQ0RbczEkQZ3wnnUMZWaouKl9ezJ7V3N8mG03Hl ZCqtsPC0zEAR05lyty2lTnmqxsDwajNTovGzXbz1X+loDjfqZVbWOC90vLeLjxckHTMw Upkk/z3f7s1HDYJhxtZodmDyiFh0Cj3jhTR0r4Y9XHnv3b+HqYgApcGZwhpZS5A8Dchi +87lozp+jF8Jn+xt35sCojp1DmavpXb70VcGDL9QqtHfMGuihyZbyoi7hnw0ZlpzE/pf UwJw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u40-20020a056a0009a800b00593b011e73esi27439862pfg.82.2023.02.23.18.06.09; Thu, 23 Feb 2023 18:06:21 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbjBXCFk (ORCPT + 99 others); Thu, 23 Feb 2023 21:05:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBXCFf (ORCPT ); Thu, 23 Feb 2023 21:05:35 -0500 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23D4838658 for ; Thu, 23 Feb 2023 18:05:32 -0800 (PST) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 31O1qK9V007233; Fri, 24 Feb 2023 09:52:20 +0800 (GMT-8) (envelope-from neal_liu@aspeedtech.com) Received: from localhost.localdomain (192.168.10.10) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 24 Feb 2023 10:05:24 +0800 From: Neal Liu To: Joel Stanley , Andrew Jeffery , Neal Liu , Herbert Xu , "David S . Miller" CC: , , , Subject: [PATCH v2] crypto: aspeed: add error handling if dmam_alloc_coherent() failed Date: Fri, 24 Feb 2023 10:05:21 +0800 Message-ID: <20230224020521.3158285-1-neal_liu@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [192.168.10.10] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 31O1qK9V007233 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758676261788060653?= X-GMAIL-MSGID: =?utf-8?q?1758676261788060653?= Since the acry_dev->buf_addr may be NULL, add error handling to prevent any additional access to avoid potential issues. Signed-off-by: Neal Liu --- Change since v1: remove memzero_explicit() as dmam_alloc_coherent() returns memory that's already zeroed. drivers/crypto/aspeed/aspeed-acry.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/aspeed/aspeed-acry.c b/drivers/crypto/aspeed/aspeed-acry.c index 1f77ebd73489..eb30649ea7b3 100644 --- a/drivers/crypto/aspeed/aspeed-acry.c +++ b/drivers/crypto/aspeed/aspeed-acry.c @@ -782,7 +782,10 @@ static int aspeed_acry_probe(struct platform_device *pdev) acry_dev->buf_addr = dmam_alloc_coherent(dev, ASPEED_ACRY_BUFF_SIZE, &acry_dev->buf_dma_addr, GFP_KERNEL); - memzero_explicit(acry_dev->buf_addr, ASPEED_ACRY_BUFF_SIZE); + if (!acry_dev->buf_addr) { + rc = -ENOMEM; + goto err_engine_rsa_start; + } aspeed_acry_register(acry_dev);