From patchwork Fri Apr 14 22:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 13212001 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 08BEEC77B71 for ; Fri, 14 Apr 2023 22:43:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 747D510E221; Fri, 14 Apr 2023 22:43:06 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE28410E221; Fri, 14 Apr 2023 22:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681512184; x=1713048184; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Wuq+IPj1vfq8zA2DHw9ThHwn0V9278qwnLWCY71S/aM=; b=ieVJ70TBW3qOn7LMCXW8AIVVA54OjjSEiITGP/DGxVDx+TV1ZdcB6HVO s3Mw0OdxgDNbJmiecCeTJp6cszVBPLL1MAi4m4w6cYXLniZd/yVjNidv/ NluVEmrxEL4jv8tcdgqedDNmk4f0dwdvqW3ZP0/GqHsAab18VolmGvMiW ixIgu19CIchOyO85VUuJ614vms0Jf4WjevTAesIO+Tt/BTq+kwvwhLt9z hrBrAze7oDt683YXJwaPv5pFb7gKjk4OQRAuqwuLixE6vf/CQKMRWP6Cb TPuWliBaZhk7DiwOucnj977opnIT/NTJ80y/UmfvMzM9sSkksWQaUlVIh Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10680"; a="407471973" X-IronPort-AV: E=Sophos;i="5.99,198,1677571200"; d="scan'208";a="407471973" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2023 15:43:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10680"; a="754607509" X-IronPort-AV: E=Sophos;i="5.99,198,1677571200"; d="scan'208";a="754607509" Received: from nofferma-mobl.ger.corp.intel.com (HELO intel.com) ([10.251.212.231]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2023 15:43:00 -0700 From: Andi Shyti To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Sat, 15 Apr 2023 00:41:09 +0200 Message-Id: <20230414224109.1051922-1-andi.shyti@linux.intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2] drm/i915: Fix memory leaks in i915 selftests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jani Nikula , Andrzej Hajda , Cong Liu , Andi Shyti Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Cong Liu 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 Reviewed-by: Andrzej Hajda Reviewed-by: Andi Shyti Signed-off-by: Andi Shyti --- Hi, just resending this patch as I don't see it in our patchwork. Andi Changelong ========== v1 -> v2 - Add r-b tags 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 5361ce70d3f29..154801f1c4685 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);