Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4597783pxj; Wed, 12 May 2021 08:58:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDTzcuLldYDOREvwuZSGeOD6Rm26pr5dIl/lqJVOUiXzn+RLS0QOymShrN3SbM+uDm0u4n X-Received: by 2002:a17:906:29ce:: with SMTP id y14mr38107980eje.189.1620835098760; Wed, 12 May 2021 08:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835098; cv=none; d=google.com; s=arc-20160816; b=gC0h+e6lPfggJc3RzPXoZ7iasEISatAdKbA4AQVQE0yqSTNBq8g0/a/l7KpOCjwByg jtQV0vv/+uRzmcwH93CFvwJdraz2sFf52YEeMYn2Ra3+cqqPbMs8mk1kHeXGU036mRSJ R/D8yY4OZ6W4axVhh1xZPoSURRpEzQp6yeX/iETdQos2LIsYDfnIybCYB8TA/4kxgIJM MHDS44MJZ7nLMdQmEhkN7Y15f+jrEyJrTsg2FwKcfr2X3wHBog6Li56Vw5khOeoCa0uU 3qVx9tqao2Ft2tOxfAQnderlw6JuIP0rTh6Zd4G2/N1/KYIp0tFkOfPlQC0hATMnwBSe r9Nw== 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=GanEdc3NpOuWdgZTUatb5E3hVZ7J5LijF1mVNKPYUjs=; b=JCID9jaDsnfikAJQ/aNsbaS2J60vcvcO17uwbU4me9c+Y8WQSmTItx/Usbkj9Y7tiX gdYyG7AVdnU/Zvz3+zlyF6aELmj/Nd+kfgUUzu1WuaBDZ9X1fU3eK1Z3D56sZ36HqKia cRY93iWjEHLxQZAL4ecyXPKhpFtc8soTOj7dD8ZCTDDq3kJb7F62QDYR+W+aUNA33gTi HF5dUHVDliodtxStQAsdVao7A6LHQ7fgXsQ+1j/nYJLM1CWQwzEvZPiu/EuElYPBozhA rtXPIUcdYNmkviu9/9sKz65UvAnAwwmau0Pu+5JpfdRHwIVvm9JO6dcDtUXPvfni3V0e scZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iQW97QJq; 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 z18si101377edd.346.2021.05.12.08.57.49; Wed, 12 May 2021 08:58:18 -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=iQW97QJq; 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 S237685AbhELP4J (ORCPT + 99 others); Wed, 12 May 2021 11:56:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:40992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235149AbhELP04 (ORCPT ); Wed, 12 May 2021 11:26:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3DC406117A; Wed, 12 May 2021 15:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832312; bh=XG0I6EgqkskKlZgYejXZ41crSv6zjD0uBky2z+qTnhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQW97QJqxsJ4HBc7woel3Jq9MnWNq0lYDUw56E2Gb911x+nWylA7cmRc3aT1SXmbz 7bM/LZmpYGIp5ufLeU597iSnMF95+mq4tDVk41prlRZ1BHeNg+dnC6VJtgUEBLC+cH 5Bh4RchGayNX9eGedFT8Fa67fGcl0nCoQVST0QWY= 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 5.10 229/530] crypto: qat - Fix a double free in adf_create_ring Date: Wed, 12 May 2021 16:45:39 +0200 Message-Id: <20210512144827.354243034@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 2ad774017200..cdfd56c9e345 100644 --- a/drivers/crypto/qat/qat_common/adf_transport.c +++ b/drivers/crypto/qat/qat_common/adf_transport.c @@ -153,6 +153,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