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: 13150914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D89A0C61DA3 for ; Fri, 24 Feb 2023 04:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hb9rPdIKpu0zqdAzVbQL+3uDWjM0m1F1pDE5ZZnW26Q=; b=iwzt10vSABfEa4 C9yvmq0r6O3jrkKFgfV2I1+JG2SD/99Rci3w16ZeGj7nJN/nnSdaHyyzt+vI7+mMysGlo/j1E8eXv 2P4ZrjfNS7FmRnN8m4XpreS89AQmhhL3mbDQBS1XczikcWQ6+P/1vdzgJkOG6HbmelFe1xs96zT0g jgQd8+tYgbxIxivM3EzUkEc3E5VrRmbrtXidIaX0Rf23KRzsvvdt2NJ7SjGoRe8qhClegqxDYvrb7 yeqA8WP3bRo6gcHStjgwyFP1V1n+DgEeeO+23kht+ABgS05WXJlUoaZTTAX9j/9++taCuueQvO7j8 WMCtqiumvZ/1qJmO6zfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVPHX-0017TX-1R; Fri, 24 Feb 2023 04:02:03 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVPHV-0017T4-Ij for linux-arm-kernel@bombadil.infradead.org; Fri, 24 Feb 2023 04:02:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=Q/sdchvZPKQHtdG6EeMgsRtDCjc6+PX/cyhIUbGD584=; b=oZNy/HWr+7Y9YsofcOTRRAAFrj oJEsG246tsBDBu3D6O5DpyBmdkU78wo5cnmNpH2fJdQPeuBNxTm4IJScR+WfEYQ8ysUlea8IFc6Eh ouTgzo/yOhyxuH+OQcgQDzguK7Hn8PvFmrtVgUBuIQ88T0S1a9z18HvkrYsrqiQT0jQVA9IbJtK3Q 0ej0vdT7OVp5zm8MCzEYCQ5mEG2T5DFA89/zM3gMNTx0kv3Gxny+UIyMDscMxCgmUF+nzXxaqr3n0 C3veCKRi/rjP63B1rjsujwnlMMGHXzviwmX/t5gWtuvlVoXzLvgOUhu7PAK6CQE0fCniaHTz3FVtP bV5cBSIA==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pVNTZ-00D6DY-14 for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 02:06:24 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230224_020622_182977_A134D038 X-CRM114-Status: GOOD ( 10.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);