Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3931548pxb; Mon, 27 Sep 2021 06:00:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0WPdNgy5mwH0XHM/C8++4KW7/RtpP7B9m1BZLsfoLWlwXHHnb+C7mk1HI4fD8ceRMc8MB X-Received: by 2002:a17:906:7811:: with SMTP id u17mr26525640ejm.562.1632747617598; Mon, 27 Sep 2021 06:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632747617; cv=none; d=google.com; s=arc-20160816; b=HHQ+onjNgwFxw3+S18ICrctg6Xyg5/+SrUDT+Rk77XUOH/dCtgabn4jQsNruBri3RU OO42fF6hAMagdqO7teibR37E+bdU/Hqrd1lSk9/rRimzurqXqDuApf7+w2UOEumxTRG7 Gle9xa/loXGy4ts3JpVx2JLCdz8CSN5OCFOG6p3UxK+HLpCscbSBTFyoeVqSG9bxetd0 71t3r9FtDDHu1SoTiW+SD5dP0bUYsJEtlqo0fATpCgOkMSyMt789DR71AsdRWSDju6Qv 2ZCGqAF8rGmgnkYLrVwLCvjfNAZW/sMymz1dNQeRc+bxM18yJF32I9M+0ufq38Frkgww 4fyQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=buipeiTZzvsTV3upLgSRicu0RTwgLOiXbgH5VGov5AA=; b=RJ12HQzZ986dvJPY9oJpkTbo5dFFDxf0E1w6pjOfGV1ugKAC8+A29xw4EhLO+7oaN0 ju2TqGfpPgYGDkaX8n8Nyb25cZs2O/iIrUoBNbdoRyESqUe0d5RqKWIhLe/3vwE9CkoY RAIQqi/e1g4jJh4to07wgZrFzouWxzarnsg4Sw/5N6ggaocxsCiKiaRMtrMDpayQXieZ Yxbw5V35C/mSTqn769FLG3D8xIA3D4d+pjTo6rXyuSvQv5Y76Hz3IraSKk7XMa0Rpxl5 otK9FgvTOMLCnFZWyxwGntnjh1xKp+GAzLM1C5kMzfBoF9SyWSyZeke/mQjhz0TZD9K6 MVYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=byJp6TBw; 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 p24si18391618edr.355.2021.09.27.05.59.52; Mon, 27 Sep 2021 06:00:17 -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=byJp6TBw; 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 S234404AbhI0NAH (ORCPT + 99 others); Mon, 27 Sep 2021 09:00:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:44042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234360AbhI0NAG (ORCPT ); Mon, 27 Sep 2021 09:00:06 -0400 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=20K=C3=B6nig?= , "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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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 * -- 2.29.2