From patchwork Mon Aug 17 15:11:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 195B1C433E1 for ; Mon, 17 Aug 2020 15:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE65223104 for ; Mon, 17 Aug 2020 15:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677892; bh=v0QKmyZbjTqae5qzYAsrlug6hBwSbq3eR+6nXGiXYbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=x0wjtxox0kU+X8CLlWfRKycTOpXRAysZmgs/6PzA8v891MnmidI7RxmBgzK5amGnf G4wnxLYDHVDPPrKVNJP1ISIZfKz3nmRr/Y143rcun5trKfwTaiJaHLrnrdI3Ja+crw g1WLpB4PBnGP+egSnrXK/PCPfx/tEB1jgltuOfIg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729692AbgHQPYs (ORCPT ); Mon, 17 Aug 2020 11:24:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:56910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbgHQPYr (ORCPT ); Mon, 17 Aug 2020 11:24:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16ED523384; Mon, 17 Aug 2020 15:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677887; bh=v0QKmyZbjTqae5qzYAsrlug6hBwSbq3eR+6nXGiXYbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHOYyOd/ERgS0J91yb0n0JGhLUrmtdknlRwFyl+vJNTcJ5zuVY5j9mfkh4fpWZzPv LGRYI0zL+L28xmJKDTTuYGkrlH8KMyWe9yjBPOCmY5ge03PrEwtHauPDraLYaIhn0c CboHUMX8zCCUA3n0XdmtkSDUhIFPikawNwYLD67A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , Chris Wilson , Sasha Levin Subject: [PATCH 5.8 144/464] agp/intel: Fix a memory leak on module initialisation failure Date: Mon, 17 Aug 2020 17:11:37 +0200 Message-Id: <20200817143840.712283432@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qiushi Wu [ Upstream commit b975abbd382fe442713a4c233549abb90e57c22b ] In intel_gtt_setup_scratch_page(), pointer "page" is not released if pci_dma_mapping_error() return an error, leading to a memory leak on module initialisation failure. Simply fix this issue by freeing "page" before return. Fixes: 0e87d2b06cb46 ("intel-gtt: initialize our own scratch page") Signed-off-by: Qiushi Wu Reviewed-by: Chris Wilson Signed-off-by: Chris Wilson Link: https://patchwork.freedesktop.org/patch/msgid/20200522083451.7448-1-chris@chris-wilson.co.uk Signed-off-by: Sasha Levin --- drivers/char/agp/intel-gtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 4b34a5195c653..5bfdf222d5f90 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c @@ -304,8 +304,10 @@ static int intel_gtt_setup_scratch_page(void) if (intel_private.needs_dmar) { dma_addr = pci_map_page(intel_private.pcidev, page, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) + if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) { + __free_page(page); return -EINVAL; + } intel_private.scratch_page_dma = dma_addr; } else