Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4510304rdh; Wed, 29 Nov 2023 03:39:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMmDDdDpAQRaeE0LpVvQvlkU1afGntKxIgBDQ/xbB/vvsGyVbHCg9MPWy7qx/5ynlztzGg X-Received: by 2002:a17:90b:380b:b0:285:da91:69d3 with SMTP id mq11-20020a17090b380b00b00285da9169d3mr7979285pjb.49.1701257948972; Wed, 29 Nov 2023 03:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701257948; cv=none; d=google.com; s=arc-20160816; b=xCrrfh3KV71awWSm0RVmQYH/7OnyML4HrKKMG6yTL18xkqFUFgCMkDFRlg4XTujjLJ sI1JUHrij4Kp8kb3S4gxEKr96xpefuULWxiLLlo6uUegij9GfSA3sFOiP9CU7N0YRI9j cLznL1nEEqlLDz9ftPAXe0VrLY4BtL2RDJ56fg+/VDSo3zaRUYGi6CpHFjBLtBh/NlxO G52IFCjHGtBYT23AyyXEClga8jXw5/4M/HSQCtBAUkgMm5nDOTUsJ4dgIQ9YydlDr46Q 93oVK99s2CCXIVKjuCqMtUxOfD2Nzc9RaM71elsDjXAuCorRzq6es+L195vhRcSIf/Bb cZpA== 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=Q+huyLHlr04ynukam/qUrI8x99v/Y58qq96yh5gLFhM=; fh=PlGs/PiSmomFQhHiE5DKIOJ9eYFYP6lcw6jsudXg+9U=; b=g+0WOyvAtS2ZLwW4b9cSto4qnr3J6rjj6wKqPgFb85M7pzTQCvxgqgU2AA7we4FbEP cILzTi2wOKKb3qhHFWJGU5FC2wqxDi4cW/mnBM26t9furEfYP46p2/rhWBB+agOfxpQi oF/2KCl2vLg50D57OGyeKMjvuu4706pc7HEZtqg4mf7iojbM/qf6iy1JECwFjodIcnlE AhKdBgdJjD6ZqyGFLoAtfScjusC9xoVgZ/xEGzbWOMGZjxeiaDyoumqI8/24xnJHhTHi UHan9MlV55jLifTMAvnuYXIFx8CmZdoDP2JiyyoibVoKaZEkjkhOvXRJsd/ntEeCKMwx D1LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aJvwWcWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id f11-20020a17090ace0b00b00280ca5f4ca5si1114242pju.113.2023.11.29.03.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:39:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aJvwWcWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1594D80B1806; Wed, 29 Nov 2023 03:39:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbjK2Liu (ORCPT + 99 others); Wed, 29 Nov 2023 06:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbjK2Lit (ORCPT ); Wed, 29 Nov 2023 06:38:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED9311AD for ; Wed, 29 Nov 2023 03:38:55 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9FF8C433C8; Wed, 29 Nov 2023 11:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701257935; bh=ufry6q9U5ZmREMm6xuUdy9QV3vgImT5VbY3R0cMBVYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aJvwWcWDK1PJDXxtbz3yC9wGeTMZuo3FPb8840B7EIqSF6i4F/8wPu5kDEiPa6ofB 6gbB2wmIIWfgoMhCftIjLXb7/KuO0LrK3d1KxMxXg0IKms07CXk79yngHABb0vMYpt a/jgli2lJ4CBc2IWCB38u8uc9LSXoPISRDpvRIRn6n4aww9Pu54+qYRwIGgjE+tDxd L3xYxJD+ReUT6ltL47ZihjKKrSxnut15Dxfzk8IDZW9kD491OvfvB2a6180IcBOPIz Bm/RXJmP0eSaHBF9z9aDiiWmutNvi5PkdrdW9a0ykMjvCALbPuMOCvpMGBv3TMpNaf MSwNSDBGCoCAw== From: Arnd Bergmann To: Frank Binns , Donald Robson , Matt Coster Cc: Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sarah Walker , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm/imagination: avoid -Woverflow warning Date: Wed, 29 Nov 2023 12:33:08 +0100 Message-Id: <20231129113825.2961913-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231129113825.2961913-1-arnd@kernel.org> References: <20231129113825.2961913-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:39:05 -0800 (PST) From: Arnd Bergmann The array size calculation in pvr_vm_mips_fini() appears to be incorrect based on taking the size of the pointer rather than the size of the array, which manifests as a warning about signed integer overflow: In file included from include/linux/kernel.h:16, from drivers/gpu/drm/imagination/pvr_rogue_fwif.h:10, from drivers/gpu/drm/imagination/pvr_ccb.h:7, from drivers/gpu/drm/imagination/pvr_device.h:7, from drivers/gpu/drm/imagination/pvr_vm_mips.c:4: drivers/gpu/drm/imagination/pvr_vm_mips.c: In function 'pvr_vm_mips_fini': include/linux/array_size.h:11:25: error: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551615' to '-1' [-Werror=overflow] 11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) | ^ drivers/gpu/drm/imagination/pvr_vm_mips.c:106:24: note: in expansion of macro 'ARRAY_SIZE' 106 | for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) { | ^~~~~~~~~~ Just use the number of array elements directly here, and in the corresponding init function for consistency. Fixes: 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/imagination/pvr_vm_mips.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c index 7268cf6e630b..6c2e4cc4e6db 100644 --- a/drivers/gpu/drm/imagination/pvr_vm_mips.c +++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c @@ -46,7 +46,7 @@ pvr_vm_mips_init(struct pvr_device *pvr_dev) if (!mips_data) return -ENOMEM; - for (page_nr = 0; page_nr < ARRAY_SIZE(mips_data->pt_pages); page_nr++) { + for (page_nr = 0; page_nr < PVR_MIPS_PT_PAGE_COUNT; page_nr++) { mips_data->pt_pages[page_nr] = alloc_page(GFP_KERNEL | __GFP_ZERO); if (!mips_data->pt_pages[page_nr]) { err = -ENOMEM; @@ -103,7 +103,7 @@ pvr_vm_mips_fini(struct pvr_device *pvr_dev) int page_nr; vunmap(mips_data->pt); - for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) { + for (page_nr = PVR_MIPS_PT_PAGE_COUNT - 1; page_nr >= 0; page_nr--) { dma_unmap_page(from_pvr_device(pvr_dev)->dev, mips_data->pt_dma_addr[page_nr], PAGE_SIZE, DMA_TO_DEVICE); -- 2.39.2