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: 13150570 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 95C68C636D6 for ; Thu, 23 Feb 2023 16:03:06 +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=Y6DL9C0ugPZx1w3dfA66V1gbMv0RI5eDUiwbtVNebWc=; b=LQeMQLOYmJx1qE U7lT4ILNjd2VLCwndZ4P40/JLvElx5/s2VEGwwfuAxO1BSyXj7Nq2uwuZEUbgAD14c2J8ZN3JteXY YSTOfUMH8EJBW0RZofs+BkNczgDQKOpVmn7niz3dL9rC22IoY0qAwj/bPr8S4dHQPXUeppmCm503r 5VOY4mAPQQH9AjZ38f10nBYchcZ0HVmNa6wrns93EN4PSLUw8srIeM5HBd3MjqWaAexhjMAi800rs 1/wsFaYwbKgyP/Ziry367g97tm/kIKuoo+VgYeigKhOO2s8j9iEdE3PWn/R9vL9APMR+W5aMrHOev YF6+rG3+oL4tYm1q2Y+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVE2k-00HAQL-GW; Thu, 23 Feb 2023 16:02:02 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVE2j-00HAPK-8i for linux-arm-kernel@bombadil.infradead.org; Thu, 23 Feb 2023 16: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=guVWGuN+YDehGZQTEb+nXbJ2FNPrlGpXe6rvLUOepD4=; b=jrO+fyoCZW5GDYTo+G6p2k/gWm d5ru3PRTdSeOjfaApQX0vfnRGM2hkiQ570/4VKRZdS32WFl985OmtiSQi1WnyY9vy2ydjWCX3EcbZ p/rQm6/kQ7FEyAmQLgxKrGeKPcc5fRP8CNHMdJ0qEELAP2SXbw+qxGayCsCDoKO17hBZedWUAmYdC f7AwoUHoxQ3tzxJSUhyuDGHYrmJRlGE0y/xpNuiq0Xe2r39Shq2na65iodu2IGARVqKRPs1Rfm6np /zV7onKsyGdBHyXs0kyTJWO+62217ErXKIg5INpOJCC5Qax/Mw6lNbqjzUeLjks4NoBWxSi4qRROa ocVi8glg==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pV7SK-00CrYz-1H for linux-arm-kernel@lists.infradead.org; Thu, 23 Feb 2023 09:00:03 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230223_090001_563330_AA89FE9D X-CRM114-Status: UNSURE ( 9.00 ) X-CRM114-Notice: Please train this message. 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 --- 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);