Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3121312pxb; Tue, 24 Aug 2021 15:56:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzngIdhysux4wyWcVoSREWde3zhkWMuJ2dkz2uJNbLs5HpbR6yQGgM2psjzqJ1Tt3Nz+UnI X-Received: by 2002:a17:907:76ee:: with SMTP id kg14mr2379791ejc.90.1629845797493; Tue, 24 Aug 2021 15:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629845797; cv=none; d=google.com; s=arc-20160816; b=T3xbkht/PmUaoICs0oFYjrhALTn27q7vHYVAJ3n6mzfLUnKobCxUDrD0541EETvNOQ eMXtYdsFqjNeHHoevqMsA+DweVirJdz2LxrtafSkGmUZFi++y7RMv/3lPkXEB20fnG0b vtaAz9ZRsyhkbSdbXDYHOvA/jBomnNfcdPZKhOZ7Gzek9ZjzrF135wJQeQ4OtOOM4GK1 IOzm15000hILoYYKVlYvyLVvL/D/yd99gGcef8WtDn0uAp7BuoAswGhw4WPYH6k3FyLG nClhiFzlJgE9W1J2OhGPBmLHo7af7F6xaDby/rb/VebY5MKozVMTtwV8hK8RnWWeUT89 rJHQ== 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 :dkim-signature; bh=cYSyZe6FOm8/g+MYyZrFY3qdXNWSltfZqcwf+VSxT+E=; b=a1xitunOHhOVdK0CGTEunMRfMHm3RIGl5iPmCGde6TXgixGDk63FMnZ6GM1Mxp80ct zu27zkj2dJ1p7fT8k2bFf82N7PsNZxMbImkY6KK9ckpxnfjYRH9jlRdc7CZxexL3SW5u /aep5uYUIsVlARZc0ZH7Ze/EMPipRHZSRriyW8Hep6ofCIiZKV/xxu9dy7uqL+CjwKO6 nIwrmvTHl5edRJui1lRGFK3WJACKs1rrE+06pNykoCAC2d3qWV83wT6wi4lJ0cWhLV8j nHKUY5xNA3WvYRorGtDzitzAFG0BcO/Vavl8L0S2DyHYR6VQSWOiiFwit2FTc4URLmKS ux3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G2reUi7c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ar12si3284005ejc.589.2021.08.24.15.56.11; Tue, 24 Aug 2021 15:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G2reUi7c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbhHXWzb (ORCPT + 99 others); Tue, 24 Aug 2021 18:55:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:49114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232412AbhHXWza (ORCPT ); Tue, 24 Aug 2021 18:55:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A9836128A; Tue, 24 Aug 2021 22:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629845685; bh=61EGsvStJTvoj2rByjNfkTgYkBZ9S/mMONay7AcUprY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2reUi7c4D2Gdx8CkPBA7QqrYRhpayxDLiITEUA35AdXbbbl8+OnyXMOglk8TnOU9 Gi8yDzqV8vrbH6rboARmfvIQEfJ+lCSVeT06ZHaCw2fLAy8IQlMOSM3tcK2uzvIKaZ ANN+X631EFzTy3QKG08vtwTDpgRn8cJRFTwks4ikjyYRmmrBV0Ag5MLCUSmXbEcwWy RNeSud//VpBm4b05r5fjuCC+15a7L9VaLbAAXbxFyihbzzOaI0lYfQcAv/Hwh5GxQj PqVvjb0VOb+nCGcO0eZoeEUFtv/LJGT3o0gbo56xshiPUNgkKuWK3VRSeyxefFHKIr yMkC+4ts0x/Hw== From: Nathan Chancellor To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi Cc: Jason Ekstrand , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Matthew Auld , "Michael J. Ruhl" , Nick Desaulniers , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, llvm@lists.linux.dev, Nathan Chancellor , Dan Carpenter Subject: [PATCH 1/3] drm/i915/selftests: Do not use import_obj uninitialized Date: Tue, 24 Aug 2021 15:54:25 -0700 Message-Id: <20210824225427.2065517-2-nathan@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210824225427.2065517-1-nathan@kernel.org> References: <20210824225427.2065517-1-nathan@kernel.org> MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns a couple of times: drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:63:6: warning: variable 'import_obj' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (import != &obj->base) { ^~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:80:22: note: uninitialized use occurs here i915_gem_object_put(import_obj); ^~~~~~~~~~ drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:63:2: note: remove the 'if' if its condition is always false if (import != &obj->base) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:38:46: note: initialize the variable 'import_obj' to silence this warning struct drm_i915_gem_object *obj, *import_obj; ^ = NULL Shuffle the import_obj initialization above these if statements so that it is not used uninitialized. Fixes: d7b2cb380b3a ("drm/i915/gem: Correct the locking and pin pattern for dma-buf (v8)") Reported-by: Dan Carpenter Signed-off-by: Nathan Chancellor --- drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c index ffae7df5e4d7..532c7955b300 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c @@ -59,13 +59,13 @@ static int igt_dmabuf_import_self(void *arg) err = PTR_ERR(import); goto out_dmabuf; } + import_obj = to_intel_bo(import); if (import != &obj->base) { pr_err("i915_gem_prime_import created a new object!\n"); err = -EINVAL; goto out_import; } - import_obj = to_intel_bo(import); i915_gem_object_lock(import_obj, NULL); err = __i915_gem_object_get_pages(import_obj); @@ -176,6 +176,7 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915, err = PTR_ERR(import); goto out_dmabuf; } + import_obj = to_intel_bo(import); if (import == &obj->base) { pr_err("i915_gem_prime_import reused gem object!\n"); @@ -183,8 +184,6 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915, goto out_import; } - import_obj = to_intel_bo(import); - i915_gem_object_lock(import_obj, NULL); err = __i915_gem_object_get_pages(import_obj); if (err) { -- 2.33.0