From patchwork Tue Jan 15 13:43:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 155661 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4906830jaa; Tue, 15 Jan 2019 05:43:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Eir/5j0ICUCuZf+vxyuky/Jy/85vC60TambCjNe/QBdLbgbqVDPbBgQPKZwciRYRdbOCZ X-Received: by 2002:a17:902:7201:: with SMTP id ba1mr4172749plb.105.1547559824993; Tue, 15 Jan 2019 05:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559824; cv=none; d=google.com; s=arc-20160816; b=UgbF1JiUJO4m3sWsmKwBfgo3ep8ojjDH/okvKItDSjfm53lGP2SJLUxgw5YGh/NjiZ yAxaed5crU2E8YwW670DplmlcdWnswpyXF6FzvtiUNkilUz/SRvxioNnkERa1TP94ZyA 7NtXpzd5x7sHE20d4Lh57rpa89aOKonokJ4fT38W/ci+WE1Ht2GG8IboDGEMyhAUhGpN CvaC6PF3qQpTY7n4uxurWoKvSkvblBS23lCrlSeBaI6OwYprDv1qCFtJBFNjF0g2+Fuq e9FvuOvY0Sz87TWOWz/g58l8Z8sU77o9cnKfYqxiF1vol4rmgodxFAp60MpJZVYPFPn2 O82g== 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 f17si3240163pgj.208.2019.01.15.05.43.44; Tue, 15 Jan 2019 05:43:44 -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 S1729892AbfAONnn (ORCPT + 31 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 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(-) -- 2.20.1 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);