From patchwork Mon Sep 27 12:58:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514686 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4090921jao; Mon, 27 Sep 2021 05:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoOfccqkkm375Ni0qVkiFj/YgbzfvI3vhl5ZLiI3kABnqdCVZe3Mxta3SukJM1DKyDjG1/ X-Received: by 2002:a65:4486:: with SMTP id l6mr16768922pgq.145.1632747515557; Mon, 27 Sep 2021 05:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632747515; cv=none; d=google.com; s=arc-20160816; b=ZE4TAy0uON7GC/R6IQdvmJLVW34c+L4nVZ7obWIHlWznUsPAaZt5aHPRdS7Z8bBxgK s4gsisB5XPnwrN9G8ft5e3qC8aOHHuA9d+7N+s+S5kFfhLK9uWq846AxAkBS5p9qsu+5 Y8U97mBYK7jSsrt+cuo0nT1oURdbRvzcmALNnqRk7As8lWj1vrnbgt8FF4Am8Q9m9aYB NjY2kwUsYRAlBBrvnUvAct7wY+r2zzwVsIGSK/Yhwzplwa9xJJcso68rPJ3zik/4Lct4 moSXbSQ1YVwGF2sZcuPjetdQImW4LXMr7kto5EDWuvZ9uv59PTqRwDsbbQSxA618Kzt5 NhtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :delivered-to; bh=buipeiTZzvsTV3upLgSRicu0RTwgLOiXbgH5VGov5AA=; b=QNeYBMYakXgRC8AO34T0EHWKiMhklr8ieyCEZckW/M5yMorjSWMzvWFDr1VcqVdBgR 774i4lcrYEUc8VE1r1wAdTS1j985ZZsBR4PfKj+FfvUqnj9aA5XW8KeLAdalVoqlaBws aYEOnVMnP10iGYB39Zj9/zFudTqZLm5Obxgj818DXxWKB3FlQ4uUs2U6GhySr+XyJ93v JSWOtD0okWUgNGbNb1A35ohFND7JVnNY97nohxEJvB+boP2zbi3/dIhbGcUJvhJADJEG CG4BztwDFuqqOo2WeCNuOsY4PsCZj8avPtiD2MXHYqa1ShiIo5Wz//0HAObVA7/CAMCk dL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=byJp6TBw; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id z4si1393056pfk.218.2021.09.27.05.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 05:58:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=byJp6TBw; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EB5E89DCF; Mon, 27 Sep 2021 12:58:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59DAA89DCF; Mon, 27 Sep 2021 12:58:29 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id A4CFD6103B; Mon, 27 Sep 2021 12:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632747509; bh=oswmBYCS56c1A9KQBHfr/N2KsORPP0gcw6VGA+01gjQ=; h=From:To:Cc:Subject:Date:From; b=byJp6TBwZwi6G+sFiUjraRb/MEzZ6qeImq1Pw8i+kMuetEZdbdVRf4zT+WPKGTAev xQSfv/18IKtOPf21332cPN1y5QIAFPH2uGg/bdS52dKb5nNZZJ24TEP8GwWrrsDv8T fRIQAs50KBcbZFzN2xwHXL9r0kWfrqfEtUKnIul2IxCp4Or4+85bnHuQnRi1e7JpT1 5moXs5IRGHSTBhrKeCM2+HaiX7ErVu+vpcDzZoQwYYmZsKy0O/GswCHyhEli0G06xc 3/EFhScMt7T6lbk70i0jB8Kqz1k7JPZV3nS3aeAgRrocM1/SYwJZArMT7U/8HHQ6B7 gikAgjt9VqNcA== From: Arnd Bergmann To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Chunming Zhou Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] drm/amdgpu: fix warning for overflow check Date: Mon, 27 Sep 2021 14:58:10 +0200 Message-Id: <20210927125824.1583474-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann The overflow check in amdgpu_bo_list_create() causes a warning with clang-14 on 64-bit architectures, since the limit can never be exceeded. drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c:74:18: error: result of comparison of constant 256204778801521549 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list)) ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The check remains useful for 32-bit architectures, so just avoid the warning by using size_t as the type for the count. Fixes: 920990cb080a ("drm/amdgpu: allocate the bo_list array after the list") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.29.2 Reviewed-by: Christian König diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index 15c45b2a3983..714178f1b6c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -61,7 +61,7 @@ static void amdgpu_bo_list_free(struct kref *ref) int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp, struct drm_amdgpu_bo_list_entry *info, - unsigned num_entries, struct amdgpu_bo_list **result) + size_t num_entries, struct amdgpu_bo_list **result) { unsigned last_entry = 0, first_userptr = num_entries; struct amdgpu_bo_list_entry *array; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h index c905a4cfc173..044b41f0bfd9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h @@ -61,7 +61,7 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in, int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp, struct drm_amdgpu_bo_list_entry *info, - unsigned num_entries, + size_t num_entries, struct amdgpu_bo_list **list); static inline struct amdgpu_bo_list_entry *