Message ID | 20230413075526.221068-1-liucong2@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp865026vqo; Thu, 13 Apr 2023 01:06:17 -0700 (PDT) X-Google-Smtp-Source: AKy350YfzJnuIxmHVz+NlUUFl8zrERjv4ZXOX0+CFYW7f+P1tn4iekMIiJYiGH1nYkNK5JZbASRC X-Received: by 2002:a05:6a00:2449:b0:628:1b3:d499 with SMTP id d9-20020a056a00244900b0062801b3d499mr2328915pfj.21.1681373176798; Thu, 13 Apr 2023 01:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681373176; cv=none; d=google.com; s=arc-20160816; b=hrpr8tYGygn2TZ7DWOZ6d+6caQactlRqzDaWMsVaNjMMQ4qqc/vgvlUsEnS9emxBLZ JNxKyctsIuWFWjJTDPlgafko+Idq1p3xciBYr0El+MpUy0LBn/zUEk9QcO+p9EkE/qzy uvT+pnsxeaGR3XAIvoEwq254K0bHnkYNr7NBaT/H9RduUukE2Dzn2HFh6TCo99eQZ3Qn DSxIM6Dx4CzV+2fun5dijj8c8bfag9mjC4PQW3MMi0TKP16C4s14lL8+isobwiFXAfxd /SqvbF96is3ynbzsyA4dmcb0p1un/B0Ntc9qEH5YkBybNA3/kznHf+M2PdPZIlSS9kFw S5Ww== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v7-20020a655687000000b005139874b88bsi1528596pgs.87.2023.04.13.01.06.04; Thu, 13 Apr 2023 01:06:16 -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 S229713AbjDMH5o (ORCPT <rfc822;peter110.wang@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <liucong2@kylinos.cn>) (Generic MTA) with ESMTP id 1709036445; Thu, 13 Apr 2023 15:57:06 +0800 From: Cong Liu <liucong2@kylinos.cn> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763030153184312158?= X-GMAIL-MSGID: =?utf-8?q?1763047560041592199?= |
Series |
drm/i915: Fix memory leaks in i915 selftests
|
|
Commit Message
Cong Liu
April 13, 2023, 7:55 a.m. UTC
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 <liucong2@kylinos.cn>
---
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Thu, Apr 13, 2023 at 03:55:26PM +0800, Cong Liu wrote: > 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 <liucong2@kylinos.cn> OK, while I was proposing the adjustments suggested by Jani you already replied to the e-mail. I will keep your version. Anyway, next time, please, do not forget to add the r-b's, in this case it was Andrzej's. Andi > --- > 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
Hi Andi, thank you for your reminder, next time I will pay attention to my format, and when someone has already reviewed, add the Reviewed-by field Regards. On 2023/4/13 16:44, Andi Shyti wrote: > On Thu, Apr 13, 2023 at 03:55:26PM +0800, Cong Liu wrote: >> 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 <liucong2@kylinos.cn> > OK, while I was proposing the adjustments suggested by Jani you > already replied to the e-mail. I will keep your version. > > Anyway, next time, please, do not forget to add the r-b's, in > this case it was Andrzej's. > > Andi > >> --- >> 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
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);