From patchwork Thu Feb 23 08:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Liu X-Patchwork-Id: 60861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp213444wrd; Thu, 23 Feb 2023 01:12:22 -0800 (PST) X-Google-Smtp-Source: AK7set+KYw2AJmlDsksq2pshwnywEdYK7DIWw3/3p6skH+jG58Qd1nfigLfIfNE8VFn44ncEGU2C X-Received: by 2002:a05:6402:35d0:b0:4ad:6f56:a362 with SMTP id z16-20020a05640235d000b004ad6f56a362mr13020889edc.4.1677143542067; Thu, 23 Feb 2023 01:12:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677143542; cv=none; d=google.com; s=arc-20160816; b=N9grRWEJ0cB8q1NLi1Z3rLbKbomSN+MergCv6TveVQsQBqjrN+9xZWXQiMQs+LxSaP 1qcrO5nRskfYag620erGPe+wh0oTedaKdE1FaWkyKtHUE9uuDbBq09SS9G5rcm8D+SQe EGS4sr9w+IpTRSWsrR+x9AKavoT2uT04M3yVJvor5w++k0tU6nPvwmKmWEAJwb8+RZrK CVslbbsZCoj/DkhTkUkzjmuPkW5L2N3aUuUcXCkQYwtbMS60JgZumqVTXmTIn8YDzjRM C/wGCNdwEWkK0UwJxLDtCpuDF9GXoY0rVScS3wBxAQpDMu/7fUdbWGI1yEkBW4+Oq3Pu PBww== 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=guVWGuN+YDehGZQTEb+nXbJ2FNPrlGpXe6rvLUOepD4=; b=XGVuXQjgIg37RWNCWjJpX5aSenQw80r/Ko0/8AalwjxK0IRLFVAAj1sjIAi4O2MsPY UkOs1ub9o/UchFQyUzoLQHK1Tvgh+u0kqvZTHui2SIOM4QshH06m9HikK2jn+WcOWwJe ZGaVjdzY+2XMuq9riPgAeCNaLJvIQakaeIjHWZbPVHyyJ5k004yNPcDejv23suHFA9dm YmH17NWEWy+lbp/O5WLI/sMxNUtYQPqSiYRvWFZSpKN5G1oN5PHWaqPk5OA0LtakfOEC Q6lc9EDJgF2ycbMRMPE2/ZxhRbSCNcU559O7ugUzazqgpuBpvEUJfwbGL5VF1B78yjEs 8V0w== 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 c10-20020aa7df0a000000b004acc19b2698si3061865edy.162.2023.02.23.01.11.58; Thu, 23 Feb 2023 01:12:22 -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 S233781AbjBWI7N (ORCPT + 99 others); Thu, 23 Feb 2023 03:59:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjBWI7L (ORCPT ); Thu, 23 Feb 2023 03:59:11 -0500 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A50C4ECCA for ; Thu, 23 Feb 2023 00:58:42 -0800 (PST) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 31N8jWZW095530; Thu, 23 Feb 2023 16:45:32 +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; Thu, 23 Feb 2023 16:58:34 +0800 From: Neal Liu To: Joel Stanley , Andrew Jeffery , Neal Liu , Herbert Xu , "David S . Miller" CC: , , , Subject: [PATCH] crypto: aspeed: add error handling if dmam_alloc_coherent() failed Date: Thu, 23 Feb 2023 16:58:30 +0800 Message-ID: <20230223085830.605202-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 31N8jWZW095530 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?1758612466898357623?= X-GMAIL-MSGID: =?utf-8?q?1758612466898357623?= 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 --- drivers/crypto/aspeed/aspeed-acry.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/crypto/aspeed/aspeed-acry.c b/drivers/crypto/aspeed/aspeed-acry.c index 1f77ebd73489..85733e418c9e 100644 --- a/drivers/crypto/aspeed/aspeed-acry.c +++ b/drivers/crypto/aspeed/aspeed-acry.c @@ -782,6 +782,11 @@ 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); + if (!acry_dev->buf_addr) { + rc = -ENOMEM; + goto err_engine_rsa_start; + } + memzero_explicit(acry_dev->buf_addr, ASPEED_ACRY_BUFF_SIZE); aspeed_acry_register(acry_dev);