From patchwork Mon Aug 17 15:14:53 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: 266383 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 EF276C433DF for ; Mon, 17 Aug 2020 16:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDF9220825 for ; Mon, 17 Aug 2020 16:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680341; bh=G2XizUJHfMayOcIy1/wif6i1wmQgrdBDThFngyfozWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LwEHMhoPBXcH5I03/XOJ6q+fwpFWo2zfVYp6kE9+Scm1Lx/mHZroYSyoNVGL0Kf0T OmPGiRJzppt6UvK1yAmjsy9604nhfpYEnaQvXuyuXyQbgtMoIquMr/VoHBMQmfYBaV 82CuNfBAa/qRMIKxc4/4z199SvOhoepyPrRbyNYg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388373AbgHQQFf (ORCPT ); Mon, 17 Aug 2020 12:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:53178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387937AbgHQQFW (ORCPT ); Mon, 17 Aug 2020 12:05:22 -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 9206020825; Mon, 17 Aug 2020 16:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680302; bh=G2XizUJHfMayOcIy1/wif6i1wmQgrdBDThFngyfozWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wWa7nBLFDx88x0inq4viILFe4Z0dAVRLF7leClgP4DSy0UY27xL1oxrLpicwzTnr4 Arlg7OZeoPyr3SJmdCZNIPGnboWDEhRCzfz0HY7ButRYHvX5CZx/O5TKBiUnqWNnuC w8gVlvrWFHHDMciXbkPWDt643Gl6Jj8UhFkRDT/g= 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.4 092/270] agp/intel: Fix a memory leak on module initialisation failure Date: Mon, 17 Aug 2020 17:14:53 +0200 Message-Id: <20200817143800.342464585@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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 b161bdf600004..0941d38b2d32f 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