From patchwork Fri Jul 16 01:11:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 12381315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1528C636C8 for ; Fri, 16 Jul 2021 01:11:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3C62D613DA for ; Fri, 16 Jul 2021 01:11:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C62D613DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C5416E8D0; Fri, 16 Jul 2021 01:11:57 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id 22DB76E8D0; Fri, 16 Jul 2021 01:11:54 +0000 (UTC) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GQtR46G3WzZkts; Fri, 16 Jul 2021 09:08:32 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 09:11:51 +0800 Received: from thunder-town.china.huawei.com (10.174.179.0) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 09:11:50 +0800 From: Zhen Lei To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , intel-gfx , dri-devel , linux-kernel Subject: [PATCH] drm/i915: Fix error return code in igt_vma_create() Date: Fri, 16 Jul 2021 09:11:12 +0800 Message-ID: <20210716011112.3305-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.179.0] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected 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: Zhen Lei Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Although 'err' has been initialized to -ENOMEM, but it will be reassigned by the "err = create_vmas(...)" statement in the for loop. So that, the value of 'err' may be zero when i915_gem_object_create_internal() or mock_context() failed. Fix to reassign 'err' before 'goto out'. Fixes: e3c7a1c5377e ("drm/i915: Test creation of VMA") Reported-by: Hulk Robot Signed-off-by: Zhen Lei --- drivers/gpu/drm/i915/selftests/i915_vma.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index dd0607254a95..96771c341f29 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -156,7 +156,7 @@ static int igt_vma_create(void *arg) IGT_TIMEOUT(end_time); LIST_HEAD(contexts); LIST_HEAD(objects); - int err = -ENOMEM; + int err; /* Exercise creating many vma amonst many objections, checking the * vma creation and lookup routines. @@ -166,8 +166,10 @@ static int igt_vma_create(void *arg) for_each_prime_number(num_obj, ULONG_MAX - 1) { for (; no < num_obj; no++) { obj = i915_gem_object_create_internal(i915, PAGE_SIZE); - if (IS_ERR(obj)) + if (IS_ERR(obj)) { + err = PTR_ERR(obj); goto out; + } list_add(&obj->st_link, &objects); } @@ -176,8 +178,10 @@ static int igt_vma_create(void *arg) for_each_prime_number(num_ctx, 2 * BITS_PER_LONG) { for (; nc < num_ctx; nc++) { ctx = mock_context(i915, "mock"); - if (!ctx) + if (!ctx) { + err = -ENOMEM; goto out; + } list_move(&ctx->link, &contexts); }