Message ID | 20230223085830.605202-1-neal_liu@aspeedtech.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;cambridge8321@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <neal_liu@aspeedtech.com> To: Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>, Neal Liu <neal_liu@aspeedtech.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net> CC: <linux-arm-kernel@lists.infradead.org>, <linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>, <linux-crypto@vger.kernel.org> 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
crypto: aspeed: add error handling if dmam_alloc_coherent() failed
|
|
Commit Message
Neal Liu
Feb. 23, 2023, 8:58 a.m. UTC
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 <neal_liu@aspeedtech.com>
---
drivers/crypto/aspeed/aspeed-acry.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On Thu, Feb 23, 2023 at 04:58:30PM +0800, Neal Liu wrote: > 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 <neal_liu@aspeedtech.com> > --- > 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); Please remove this memzero in a follow-up patch as dmam_alloc_coherent returns memory that's already zeroed. Thanks,
> On Thu, Feb 23, 2023 at 04:58:30PM +0800, Neal Liu wrote: > > 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 <neal_liu@aspeedtech.com> > > --- > > 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); > > Please remove this memzero in a follow-up patch as dmam_alloc_coherent > returns memory that's already zeroed. > > Thanks, Okay, thanks for the information.
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);