Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4237951pxb; Mon, 27 Sep 2021 12:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTIpq8wGNYvV03GJNPkSH/KiON8MrcVyGcfo49GBKPhEl9Bw9dPwzu1JE3/ZkoZDtZZn9M X-Received: by 2002:a17:902:b7c3:b0:13e:1d55:51d4 with SMTP id v3-20020a170902b7c300b0013e1d5551d4mr1386507plz.24.1632770522894; Mon, 27 Sep 2021 12:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632770522; cv=none; d=google.com; s=arc-20160816; b=HP4aR6Er2Z6NpQeOcRzTtsXH9VoeCWXvV/5h7rBcIkeh3qbeOak8gf7MPCYVvLI4kL YF2h43C7Nvy9oEWUsl84JDaNRpycWFH5JostjtZYcj6p472h4X1g/Yr9l7Wr3x9s5Gn5 Wge50xCqJJytTQdbrF5syCAb5amJUrftJxrQo/dFgagrwbuMG1EUtDWiiRisAoz1AJsf 5Jpa2CzObe+SYT4EhOo4YuFV0GhZATpqW3Ff9Cfo1m18+CCVPnme3rk5mZaryQxbUgoO 6DzRhVnTTxxPbn9x5ZKnIkz1OYGHEomOLZlK/GRO59PS6LBvB9xijPRq3NS1TBCY8xhT ISLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DxxDnArAuqMzLOKrnNqBxORaTd+7/JcrK9bDcFPx9BQ=; b=UHYmZiMcAY81wJdHyCOgBTiYrDn0WZCVii0GMslgnSPmY1JpjSIfmNdnzsy9k48jCu K4d6FDQ0ZsvUTpDtLQbZ0SEQ0KKwYFJyYCZn5O+CIvsei0/rEtFQOQH69segsgpdV5Ae DrPtHjU7IFTJsyYaBoVy9NOag9J2QCz4qibbXxcEzWX2TK1O3ZM9IeIlN0DB1YOCOrRO mDMbyse7CNA2MEJrK86i2TXRSsr2VaZ4BGN+L6Q/49vj6yrMfOuQ66yLBs/r8DtCzTpO f0BAmXPx3Rdb8AJiEsBwiVWAtzzhMTf2mkTpbHL3/5pkpGkQZ3FARp/lJSzwJf4Nj7Ii ubMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E9fwq5bT; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si472460pjg.160.2021.09.27.12.21.49; Mon, 27 Sep 2021 12:22:02 -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=@gmail.com header.s=20210112 header.b=E9fwq5bT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236402AbhI0TWG (ORCPT + 99 others); Mon, 27 Sep 2021 15:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236225AbhI0TWC (ORCPT ); Mon, 27 Sep 2021 15:22:02 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5094C061575 for ; Mon, 27 Sep 2021 12:20:23 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id z11-20020a4ad1ab000000b0029f085f5f64so6352159oor.5 for ; Mon, 27 Sep 2021 12:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=DxxDnArAuqMzLOKrnNqBxORaTd+7/JcrK9bDcFPx9BQ=; b=E9fwq5bTre/IrnXwZ/2oEJhk10H+KaHc08PWNXgjOdhLuUJdU3V/PDBPGGcH4aB6EG vbqUjNv9ClfzM9n9n8OdWHiQaBYKlO6riTNMumO2z35RshxodLeNmh7FEphBSza23fvF /RW6yO5Y0JV916oTome5iBE3PMnJ8aCKZ1Y4XPDKv5YQH18GO90n97xXLlEQrSgNK6Pi /P2EQmG63tM/8mFlDUzWK5I3KY9XTT6C9zdrUQTveO3EcOCxrHQIHB2omyozhfaGhKo9 XQFrYfgyss99y3+08WWPCMBbbsvy8SoaCiwiXiBYZNmvO7Wkm/vzlC6JgSRNAiofslBs IsUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=DxxDnArAuqMzLOKrnNqBxORaTd+7/JcrK9bDcFPx9BQ=; b=2VVJWLAWzpGwuLoOaNqwsj7JstkBbtuuAhY25YEw7Px6LHXcxTqviB1gHm9fux6YEC QfcN24QrRXzGHuhLK6vAEvhmOx3cRnqzYW8TnWUGHM25Vom7j+xuGAVZa9/PCmXLBUkH p1/aFwXS2pNZFhV0qUL9LIq7VfuF3LhwUJa/ogY1Amip49Rvvh2gZqkyThsgKEUtpcxg rqPeyou8Hg/IX4zLiQ+1MEhikhpQQ4SvqIu1S2s/yMFtMgDFoKabcsmKNj0w3mJPI56i 1Aufr//QKhSmCZB9NJQPhTE0pA0OS9W/bvK2cNdYRUQ0V+LxOicGsjscvV2Ns4uph32T FLvA== X-Gm-Message-State: AOAM531/7IEBZQbIm3bHuwLIh0tpqPSfNJQ1/xmVKtSBRwOMQSHDTo8G FMX84UrgInI56vtMzjvrzNtJRFSRYBDDCL6Cpg4= X-Received: by 2002:a4a:e899:: with SMTP id g25mr1334984ooe.68.1632770423330; Mon, 27 Sep 2021 12:20:23 -0700 (PDT) MIME-Version: 1.0 References: <20210927125824.1583474-1-arnd@kernel.org> In-Reply-To: From: Alex Deucher Date: Mon, 27 Sep 2021 15:20:12 -0400 Message-ID: Subject: Re: [PATCH] drm/amdgpu: fix warning for overflow check To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Arnd Bergmann , Alex Deucher , "Pan, Xinhui" , David Airlie , Daniel Vetter , Chunming Zhou , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , amd-gfx list , Maling list - DRI developers , LKML , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applied. Thanks! On Mon, Sep 27, 2021 at 9:07 AM Christian K=C3=B6nig wrote: > > Am 27.09.21 um 14:58 schrieb Arnd Bergmann: > > 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 com= parison of constant 256204778801521549 with expression of type 'unsigned in= t' 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 > > Reviewed-by: Christian K=C3=B6nig > > > --- > > 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 **r= esult) > > + size_t num_entries, struct amdgpu_bo_list **res= ult) > > { > > unsigned last_entry =3D 0, first_userptr =3D 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_amdg= pu_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 * >