Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2654835pxa; Mon, 17 Aug 2020 15:38:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjbsxSpD3RmBmzDU+D6BCNtcLq6VvI1eDuCqqehrQrC+4UbTIw0f9adz54+b5qlLdh9P/e X-Received: by 2002:a50:d942:: with SMTP id u2mr17815532edj.0.1597703905681; Mon, 17 Aug 2020 15:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703905; cv=none; d=google.com; s=arc-20160816; b=E6iIQVKOXwSifiWzykX4YlM88sFgC9lcB4wsZkVafwhTqnAy+WEsu0gmhOZAkGyWVV 8lcVK0/LWXhoFHjzm/eMgEscVa0aVDHqg0iY+4NFPzeUJ2BWbKf/F341/rCWnNP3VQwm RvcQGyLgsx7GPPqJMqL3fYZRGh58aPQm+pydtvLzHo2fiuhYAVDKoZfnlq9QjnYTqk86 ZCb3dnJpf6q2tGs2KSBVjSyV/ROyUrdzPmnHGrPuQxmb8EsL65E1RxeCagggpldAPOeH TzJWrn2Hg4bH+q1hMfMbj7WMiEL/HYK+5lE0pt7NHLzGQ3JdO/hS5d4bn7o9Oph0AnO8 MgZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qViV4t+FqqSzzo7AqNGbn1iCD7AOobiiQV+0gp0Q6NY=; b=sbYtX46cmXY8D/mKn5WSHe2/p9YdfoTW1Wm4oLT757CZfiwZbWOWCgLgF/DoXCVI/x N6JKWNFZ1NWD8Z8wStJ8Wvzvs9N6NIFnXiAPIx5iS4SiIWtufHyDYK5TyYfzZF6wEyoB wTwvMgMiXgfNL01zyCC77L/UU9yYbgod4bkoJeYeQqosyyX+YqPFQeQqPIbe55rBez81 kv5WDuFE1WcQy/Xwa90NGkG7GGCbnuBLRmvuhF4btPDREDQmpxoOXTYP4IUvhBnxHJhN 6PzWcAxSkNjIUp6zyjPSHV34vm9tziLvDmLspr3ZESiDgrRVmiB5gjJQ4XJ7Z4eQ2O/T jabQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K0cuWiDi; 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=fail (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 v15si12092917edy.90.2020.08.17.15.38.02; Mon, 17 Aug 2020 15:38:25 -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=@kernel.org header.s=default header.b=K0cuWiDi; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390105AbgHQRsv (ORCPT + 99 others); Mon, 17 Aug 2020 13:48:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:46226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388741AbgHQQNE (ORCPT ); Mon, 17 Aug 2020 12:13:04 -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 982B0207FB; Mon, 17 Aug 2020 16:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680784; bh=G2XizUJHfMayOcIy1/wif6i1wmQgrdBDThFngyfozWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0cuWiDim71stRrjmp5sWJaxND87Jg7rxBh4Gf4bEUn8F5gacDbOg+7LcCTIfBxwY Ws1ZOE8w93rhqQItfcqcalAfvTLSBQWRGFWaDUvDMOEAWLv2v+XDkgwuyGnLzFsQYA 6sDF3XxMXEA/w5uqU2YIkee9WXV4qVA5Bgbtxyzo= 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 4.19 055/168] agp/intel: Fix a memory leak on module initialisation failure Date: Mon, 17 Aug 2020 17:16:26 +0200 Message-Id: <20200817143736.500580132@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 -- 2.25.1