Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4784864imu; Tue, 15 Jan 2019 06:03:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN68xgLnL8j0c7EloX/GTy1fLO7meYQrAkEM+3D2S0eTDcngGKZ8aho0Ix1ukpM2nlmj0umM X-Received: by 2002:a62:c583:: with SMTP id j125mr4219922pfg.37.1547560999236; Tue, 15 Jan 2019 06:03:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547560999; cv=none; d=google.com; s=arc-20160816; b=YvUrLXzdVnW5skFwn36qAppNUkAW2gdFMKeYn6PleFsdguMzGQj6U04D2v1u3ueGAR a2tOc6csIBBotzcXuhI7/s3xQ+Q6aw6Q0Tlyg/jlPL8AywBEcrm69Le68rT1fgOf3Ni1 aYvCFMLS6AquwHbW/6iA71Fzy8zu5jA87f/Ep2PsRGpv/+cWwCKWlpDblIY4SqaoCtED VNt+9WjVPRABk0HlPhI7sTBshwKuhBpipYhf0SLWcSfAwyCuxa0gAfyftIa+hH+vkGzP Jd+CjoQSgxK5GE3cpVhlXIOpZ23hR/QRNZOtOF9fNsKN2uZMgJHP5L6lzcGFCXyWu5DM llyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qC1Casu27NFS6or0Ka1NITjp0xAjlYvECFcNRcq9Fmc=; b=NSLuYq1DDwYPR2Bz9dsAJHdxTJXcTz5DB/SNeG93u1M95ID9co+6s2F8sLANSiRYkH qeaxKyPbOo2R9dA82B6srjCwHlaY4AGDMwYzLIqo2shFMFrneS0ujVQ/b3lxN8AMzQ5y 7UTqkwdH2UejRHhMtXsI7SVI5UCNy6BOm98RQX/NyBiMmH8epTnRgJt+mvQ1C0lMvA/5 jHTmiY4LlHcPuMJt92CGl+zg8GYh/sRfIOGprp/QAi/RBSntSysbiFspZpoyARHuDcwM 4Dv/ClqjaQ35v9WmlflZ46wHBTMAQ2eV9/fv3hfB7RZE9+PkN5r52xu0ulV6pNNRAhm5 SoWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 189si3367772pfd.142.2019.01.15.06.03.01; Tue, 15 Jan 2019 06:03:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729887AbfAONnn (ORCPT + 99 others); Tue, 15 Jan 2019 08:43:43 -0500 Received: from foss.arm.com ([217.140.101.70]:50746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729245AbfAONnl (ORCPT ); Tue, 15 Jan 2019 08:43:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F843A78; Tue, 15 Jan 2019 05:43:41 -0800 (PST) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 905783F70D; Tue, 15 Jan 2019 05:43:39 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Hadar Gat , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] crypto: ccree: fix free of unallocated mlli buffer Date: Tue, 15 Jan 2019 15:43:13 +0200 Message-Id: <20190115134318.28712-4-gilad@benyossef.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com> References: <20190115134318.28712-1-gilad@benyossef.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hadar Gat In cc_unmap_aead_request(), call dma_pool_free() for mlli buffer only if an item is allocated from the pool and not always if there is a pool allocated. This fixes a kernel panic when trying to free a non-allocated item. Cc: stable@vger.kernel.org Signed-off-by: Hadar Gat Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index 237a87a57830..0ee1c52da0a4 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -614,10 +614,10 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) hw_iv_size, DMA_BIDIRECTIONAL); } - /*In case a pool was set, a table was - *allocated and should be released - */ - if (areq_ctx->mlli_params.curr_pool) { + /* Release pool */ + if ((areq_ctx->assoc_buff_type == CC_DMA_BUF_MLLI || + areq_ctx->data_buff_type == CC_DMA_BUF_MLLI) && + (areq_ctx->mlli_params.mlli_virt_addr)) { dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n", &areq_ctx->mlli_params.mlli_dma_addr, areq_ctx->mlli_params.mlli_virt_addr); -- 2.20.1