Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2637685pxa; Mon, 17 Aug 2020 15:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKPPGstF13CT5n5jUF4q+BKMXruCg2ht3bRM06r+QBWXggtrMLIojN54Qb8dCa8x2FoPxK X-Received: by 2002:a05:6402:b32:: with SMTP id bo18mr17218628edb.201.1597702073869; Mon, 17 Aug 2020 15:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597702073; cv=none; d=google.com; s=arc-20160816; b=ZoD797iQi9Lkx67Qha2CEql/9WjoekTa19NOyozQ8wym0ev/1Acw2oraXhZmhJd2MV BN/u06/VePxBLPfO1SESks2rtV5+yn3S6FmmfRvXbD/PH5VZmyJuY/QUTQ0ULxoDbE9c zP3nevAeF3KMozjY7M7Cp0uV7Qi3kjOyhWCMwtA1Udhp/srmLfUkr4CPmA5Iwreie/OZ 5yyCI4MIR9/3YMm7f4b8Row4ZgVzJeLtVQB+NdtqL92iq5CzIs7giEGv9gmxQ+H8uGVz VG0vpLfaGDiUrwQ+B6IpE/uUtjXv6NdwHpbNyQBXqBfq8KkAjNImzeor7PU7wcf3+ThB G0ZQ== 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=0z4dT3/FXWyi5EtGMWrQ7hLK8IHnRxGM6yXDDT75yjs=; b=cshqBny3YrIfKSRCxDKR9tTQlP8IJYSxwmsfJFhDtsUDObb94Wguel66pDH8cS/cQD pUQwtS7fzzANJUK0GVaX/m4uiD5YnIQ+NdAfJk8AWUpUcBOl7T+2CirNpZ4BdLdf7Pyv q896iMhWL53b1MGfqP48erHSNI4Hex3YvZhVwM1hI9ItaSW396ZKkm3yrIenXuNM6KSn ptkg5GsiBL2FjANFM9liMLTWIa4r8uxbIAh4Ot5/XHg5mEm9VJQsSO7FNhkwbSOa+m5P qWVxo0Lbf2nDWjP5ltQ2OUGNHpke0pfiZO7BtssBOrwjqREnvGLGGjzKC2NWpQF7IDhj G5XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dhGb8Fc7; 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 yd22si13704413ejb.33.2020.08.17.15.07.30; Mon, 17 Aug 2020 15:07:53 -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=dhGb8Fc7; 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 S2388760AbgHQQPJ (ORCPT + 99 others); Mon, 17 Aug 2020 12:15:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:60062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730829AbgHQPr7 (ORCPT ); Mon, 17 Aug 2020 11:47:59 -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 908A422BF3; Mon, 17 Aug 2020 15:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679278; bh=mZWLiMPkpmDjh4VWJYTnOjVF9SLNOL9q16QWCdKWD1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhGb8Fc7wmybUFRAzkRsxfRnfDjPeFGOWlnYpE9FVSQXw2n/zUvVXx9Nylt9JsCEA G9dYUTmVyAo6ScEVMd+V+0pAQSJwFZRJmEQnX3UZbwuoN6FQQtuKpYaGlcvd2WLiDb FFCFtaZNx/Xa6sJjqmLx8SMaGx1fChSQXInoH2wY= 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.7 126/393] agp/intel: Fix a memory leak on module initialisation failure Date: Mon, 17 Aug 2020 17:12:56 +0200 Message-Id: <20200817143825.718469764@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@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 3d42fc4290bcf..585451a46e447 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