Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp340437pxj; Thu, 20 May 2021 10:30:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMQyZWolSuqeYuO8DV7OBno2eNRQc/DkNw0CMZFNDiEkGTRfSZ1/GYV07UBbr7HvtogMEv X-Received: by 2002:a05:6402:3098:: with SMTP id de24mr6017885edb.339.1621531833725; Thu, 20 May 2021 10:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621531833; cv=none; d=google.com; s=arc-20160816; b=OoGavpcTvQSEVotz2WIf3a3cjvv02loDOcIRmCvkrz4AY1yNzgsRuoN6KtyhpOlokI YX1j2GDFOE1eyDdYTktZf8UgjtfTvspq187HsWaw7FfkekodFy39DyCjBOqdIxgZHNqV Ir+L9UkbeIrDNxRdaQovHI2O+uu40R+tJKiR2qf5xY3YU5JSns7fZ1nXf9A8gaUvxBcO sz7U5BxuT5rkeyi7/E0SXWipJvLMGpexITk0Ts+BfJrlBbNrdM3nkn+hQmKrdCmO0ood wfLqSfce7eOMVhNr+adf08W8fyUMPRWF1xehmH4Zczn7elh36yZCTYcMgzbal2BFkcPs eJIA== 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=bSrkjkDQpNyFupF551iZ39rmQv+4YdeP8H8ovzvaVAvcRO/vU2fiXEZN8wZ5eEar3s y7AcHeZkjZyqq94+FhQ6AMYeXV39X0f86J9kSpNuQWaYTIUqTqkRCB1tcAEoCqtq7kE6 L1R7lBYL3H7yUEeYTMt3AIyFiNwSD922k0qNd/3qaVkfqFIbvrbThqYyYaS3/l5m61d7 LVKhxBq7BldrpIEQcUXLRoqZfmeXZ/vQqCN9t7TWDQa80zuR+STz2krL1kRSisYsP5bu oEmFhOmOKIIDfnpGm77FfBUkT5o6+nSoQ9r8BNgSn56C/6LDWmRd991FG1TpqUTmb0HN 9New== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SFmetlKp; 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 z11si2791590edd.228.2021.05.20.10.30.09; Thu, 20 May 2021 10:30:33 -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=SFmetlKp; 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 S235179AbhETJ5o (ORCPT + 99 others); Thu, 20 May 2021 05:57:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:53284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234672AbhETJxz (ORCPT ); Thu, 20 May 2021 05:53:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B615F610A1; Thu, 20 May 2021 09:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503403; bh=8APKXRuvakIe0b/7cybuTVvzfs8YW/6wc5fHM9HTOAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFmetlKpnvEXHsTpZuUCw1xkBRpzyRQcs25hVwHFwY0jxiatXDyvaW8owbbREi/uh k2CnVE0k8GWV9OVH129Cq3DFY1GWaEJkU+tdRkZaentxia4525djfUfz95xPJGNUn/ 0DjZWGYeKV7Tb9WL0CMDW6qjsTROD2h332Np3IR4= 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.19 205/425] crypto: qat - Fix a double free in adf_create_ring Date: Thu, 20 May 2021 11:19:34 +0200 Message-Id: <20210520092138.149043617@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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