Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2080964rwl; Thu, 13 Apr 2023 01:05:51 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQlmQuHZonTIqaBegySsJFJomYH+i632pv8iKNWzQ+Yerada43GQ9xH68Fq+hrpc3oNdsF X-Received: by 2002:a17:903:245:b0:19f:1f0a:97f1 with SMTP id j5-20020a170903024500b0019f1f0a97f1mr1620789plh.30.1681373151040; Thu, 13 Apr 2023 01:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681373151; cv=none; d=google.com; s=arc-20160816; b=MxT682L4P45KXMpEbzwIsnHJM/iBu33P7U0X5OlY55OaKgR5YJyHfRQ6maJPpKeZ2B 7CgmTlR1EKYeUzt03zkkbxv3u8vrPPo+j1e284gOOsduhz9EdEa/LFz9fzYR+OWnzr4q To7MQ4gzBVkXoGnn2LG0qk0DCgLIFi6ZEpkiuOmsg1DmSUV9Z6Wsbs7uCVpAArvTvyP+ JpMGwuWdEYS77rVYD3+Ar93FOIvuOvHGlsrxcHC91jxDCGFE9ZqNyOG9u9Vv6G7nWY+r IHXKEu6qoZzowEGnuKiVBlMxJwHotMUlENiy0oKFeC1vH98PlNBmwl/weTH02NDaLAD3 8ZVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=w0y0FW5NQg9y8wg3cMYBlWt6fmQYKGH5WES/R9zH1Qs=; b=PzAa4kCRXAt8HQ7LL3OgXWUWyOFa0jlCCJxwBkz2LTgN1Rxk9fGR2XOkhX9itVE+xb eA98QmeW3wi8yIx3qODEzeakln1i5oml4TE7HiFEmGiez7p2WsX/m2P3+MxQB63R+Mgt tWJDlmn8AxHSwfze0uqIwcv6tu7FoxmX6EuPzXvx008L7/BSZGgd8LLst15PVXPttFAp CDCsPRmb0TLUarB2NhhtlAN2JDLLn/wW9f72d5v/KKRwgIuuO79i0mTLuqyRxme/Vfve GlJKzACQOOoZBSpL0vHxdO//FFM67unxTaZm8u+Lz0kMX0QCHzEgBlfdb3m7So2nrqI9 2HLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a170902b10b00b001a288c5d34bsi1437969plr.85.2023.04.13.01.05.40; Thu, 13 Apr 2023 01:05:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjDMH5o (ORCPT + 99 others); Thu, 13 Apr 2023 03:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjDMH5m (ORCPT ); Thu, 13 Apr 2023 03:57:42 -0400 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB8093CB for ; Thu, 13 Apr 2023 00:57:14 -0700 (PDT) X-UUID: 523ffd16c1d74ba2bebaa48baf1044d8-20230413 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:e27458f9-b223-4a29-a75f-dc1628b0353d,IP:5,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:1 X-CID-INFO: VERSION:1.1.22,REQID:e27458f9-b223-4a29-a75f-dc1628b0353d,IP:5,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:1 X-CID-META: VersionHash:120426c,CLOUDID:952432a1-8fcb-430b-954a-ba3f00fa94a5,B ulkID:230413111352DVZVW4B9,BulkQuantity:2,Recheck:0,SF:24|17|19|43|102,TC: nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0,OSI :0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 523ffd16c1d74ba2bebaa48baf1044d8-20230413 X-User: liucong2@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1709036445; Thu, 13 Apr 2023 15:57:06 +0800 From: Cong Liu To: jani.nikula@linux.intel.com Cc: airlied@gmail.com, andi.shyti@linux.intel.com, andrzej.hajda@intel.com, chris@chris-wilson.co.uk, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, gwan-gyeong.mun@intel.com, intel-gfx@lists.freedesktop.org, jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com, linux-kernel@vger.kernel.org, liucong2@kylinos.cn, matthew.auld@intel.com, matthew.brost@intel.com, mchehab@kernel.org, nirmoy.das@intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com Subject: [PATCH] drm/i915: Fix memory leaks in i915 selftests Date: Thu, 13 Apr 2023 15:55:26 +0800 Message-Id: <20230413075526.221068-1-liucong2@kylinos.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <874jpkckxw.fsf@intel.com> References: <874jpkckxw.fsf@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes memory leaks on error escapes in function fake_get_pages 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); -- 2.34.1 No virus found Checked by Hillstone Network AntiVirus