From patchwork Thu Apr 13 03:13:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Liu X-Patchwork-Id: 13209943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29053C77B6C for ; Thu, 13 Apr 2023 08:33:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A8F010EA6D; Thu, 13 Apr 2023 08:33:40 +0000 (UTC) X-Greylist: delayed 304 seconds by postgrey-1.36 at gabe; Thu, 13 Apr 2023 03:19:05 UTC Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9C6310EA17; Thu, 13 Apr 2023 03:19:05 +0000 (UTC) X-UUID: 2af2d65a6c6840df86ab547bf360109b-20230413 X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:c30541db-2ea1-4af6-9267-42766adcc549, IP:5, U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:8,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:8 X-CID-INFO: VERSION:1.1.22, REQID:c30541db-2ea1-4af6-9267-42766adcc549, IP:5, URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:8,FILE:0,BULK:0,RULE:Release_HamU,ACTION: release,TS:8 X-CID-META: VersionHash:120426c, CLOUDID:1255e483-cd9c-45f5-8134-710979e3df0e, B ulkID:230413111352DVZVW4B9,BulkQuantity:0,Recheck:0,SF:19|44|38|24|16|102, TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: 2af2d65a6c6840df86ab547bf360109b-20230413 X-User: liucong2@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 30789537; Thu, 13 Apr 2023 11:13:51 +0800 From: Cong Liu To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Matthew Auld , Andi Shyti , Nirmoy Das , Andrzej Hajda , Matthew Brost , Jonathan Cavitt , Chris Wilson , Gwan-gyeong Mun , Mauro Carvalho Chehab , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/i915: Fix memory leaks in i915 selftests Date: Thu, 13 Apr 2023 11:13:49 +0800 Message-Id: <20230413031349.9026-1-liucong2@kylinos.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 13 Apr 2023 08:33:23 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cong Liu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fixes: c3bfba9a2225 ("drm/i915: Check for integer truncation on scatterlist creation") Signed-off-by: Cong Liu --- drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c index 5361ce70d3f2..154801f1c468 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c @@ -69,8 +69,10 @@ static int fake_get_pages(struct drm_i915_gem_object *obj) rem = round_up(obj->base.size, BIT(31)) >> 31; /* restricted by sg_alloc_table */ - if (overflows_type(rem, unsigned int)) + if (overflows_type(rem, unsigned int)) { + kfree(pages); return -E2BIG; + } if (sg_alloc_table(pages, rem, GFP)) { kfree(pages);