Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2116840lkv; Thu, 20 May 2021 03:48:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6XSWLmr7+38Q2rJuzFXo7+9qm/eL1dhGFVyKdabm5wAFmFrEwkBOSQvKPv9Y/KVIhnwHK X-Received: by 2002:a17:907:1ca1:: with SMTP id nb33mr4045166ejc.75.1621507711516; Thu, 20 May 2021 03:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507711; cv=none; d=google.com; s=arc-20160816; b=MtbnhCzV0LZSazHkrzCF03eF1VZyUe5/ll1c1Zy/gVn0iVK3Qm9SKG+geF1dLpQMVh 46GsACSWY/rCoDQsx+EzncS6Fnuc4jbg5M8kTVGINemToObwF99qG69uYxcpY3g4ALrJ afFCcSnr2spi0Mvj8muxu6PO03O4+eClJ/iTY5xg2Wc7VfCgNVygb+QhnVqYEdEZyX2X yZEDNXFwZeIAsOEWCv9aPgAVnNT9rWdDcvnYbdBjWAZr4sBXMQSWOWaVVjwH6PellfCn dKrzL4FXOvueoTS21eVReM/l/olFweU1oWcokOEKhEtu3h595CiOkZOysyf9r3Wh72vT Zh2g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1IgyvKwH8KmMgGKbYC+wQzacWiXcS+wZ+rDye7Lgn/o=; b=GaJOn4nJnTy4MkgMDAs4nNk4LsKLglShazXf5uSGsqZhd+srPn2nYwa/YXvXNZ4a3S WrZPw9aqLsZKvyg8EqfM33esc41svYKYj3lN8qIlZR7brNhJiUMZVS80KthZptFqBJ0E lTwBoo/j/TxvDClZSv1gjlb7K6D15pB9+NTZoSUMI1dl5UodJmLyol6OIFnDYkZUYRxt TE4R6D+Sv6HA3CyVanZmVjOUvbmqcourwZZdUvL8KV+CRf6uV9SR+N+CaAf3G4EV2wpP lEAiY0vv0XD2lZTtF9flLlrg+79ZzX3ASiNkzxu037GYeF4a+BcRBzAFLtslyQ8BdKmP 8ILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L6XKhkax; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si1967486edv.421.2021.05.20.03.48.06; Thu, 20 May 2021 03:48:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L6XKhkax; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238381AbhETKrd (ORCPT + 99 others); Thu, 20 May 2021 06:47:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:60494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237324AbhETKbm (ORCPT ); Thu, 20 May 2021 06:31:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9DF4861C3E; Thu, 20 May 2021 09:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504343; bh=8APKXRuvakIe0b/7cybuTVvzfs8YW/6wc5fHM9HTOAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L6XKhkaxsfqrjn/nYKrb9a90AFOjbHLYppBCymrdbe2rhQV3QcAtKIY8nEekpSRsv 7VyC3FOsCq8RfmaqUBeIV+jvFHGpFsh/kpblNifbdBDPyg0uIzEsqQnJx/umv1Q3UD 2Ti5W/0ZiunD7OH6rbkGewt8H5AeFI7ltCydk1UM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , Herbert Xu , Sasha Levin Subject: [PATCH 4.14 169/323] crypto: qat - Fix a double free in adf_create_ring Date: Thu, 20 May 2021 11:21:01 +0200 Message-Id: <20210520092125.897610294@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Yunlong [ Upstream commit f7cae626cabb3350b23722b78fe34dd7a615ca04 ] In adf_create_ring, if the callee adf_init_ring() failed, the callee will free the ring->base_addr by dma_free_coherent() and return -EFAULT. Then adf_create_ring will goto err and the ring->base_addr will be freed again in adf_cleanup_ring(). My patch sets ring->base_addr to NULL after the first freed to avoid the double free. Fixes: a672a9dc872ec ("crypto: qat - Intel(R) QAT transport code") Signed-off-by: Lv Yunlong Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/qat/qat_common/adf_transport.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto/qat/qat_common/adf_transport.c index 57d2622728a5..4c0067f8c079 100644 --- a/drivers/crypto/qat/qat_common/adf_transport.c +++ b/drivers/crypto/qat/qat_common/adf_transport.c @@ -197,6 +197,7 @@ static int adf_init_ring(struct adf_etr_ring_data *ring) dev_err(&GET_DEV(accel_dev), "Ring address not aligned\n"); dma_free_coherent(&GET_DEV(accel_dev), ring_size_bytes, ring->base_addr, ring->dma_addr); + ring->base_addr = NULL; return -EFAULT; } -- 2.30.2