Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13036012rwd; Fri, 23 Jun 2023 14:43:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6XfnljKZYwgbR84/iB3bspCgBv/yTwSfrFikSq8IV3PyZbjTDIUgDi0fQukuj5ZZxIY30k X-Received: by 2002:a05:6a20:1585:b0:122:470:377c with SMTP id h5-20020a056a20158500b001220470377cmr20057088pzj.2.1687556623580; Fri, 23 Jun 2023 14:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556623; cv=none; d=google.com; s=arc-20160816; b=eANbTUFDJvzwUw/Gp5YqEvm/ZSBTz8AfddCze70+gHxqrfPhXMNJMyMRyyl/qqDpcI juonS+z8SyA8q8ZwdmrwplxX0rvFGmmoTeRX09niYKQGZahaWKqxN9gxOZxtKDl6LIlM yrjXgnUWii2E9ZpO1BcM2XQmDsFYj1GCheOAE5ykenMCfMCUm1FUUnsrBvdFxbj4cmq1 akPkfhIkPdy6Sm43BndrfVTEicnfyJkM/WpW4zSFx4ixJuFJtSH/6NDrc3Oj+MsEsMB9 8Qedxo6OTjSxfq1txrOmVeuJBBNV7xYK6yWnbpmbOYpT54pvzSlekfDh1aa5OqPl+Hfj C80g== 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=jammjAxbCgbnRHLqhi6UIftAryvqKnOHjwdJrbKzjag=; fh=DE1wrYw37yRMyqW9rtnAxlFdtA+6nyPKla9TFht66fc=; b=GikxxejsXS60wNmNpB10HhW8ofiKsHGzlGPKQ3re0b+cjq5nfL5vZgbgRElz0pprAz yjwsKiZb8cMW64nbAs9Vl/lnTbR3dTXQL+/g+2Kl1kILrKWQbmMdD8pimOmnxRAZfeJP YfPWq8dGid3U2FtvJTEfsmb9QELpLqcAxNE6KNJ+QzfRnvgrOl4fpiBGpLsL85ZMCUcp +C+WBElb+en6ttRVaiyGSoq7dChAh78qMxgqbEqaNC+TSOtMGP1nFrJkRfPH9tU72ki4 CRZm/uAqn74DwJ4h+Ottro7D8BuUlGVnQORTdvbPPzMrt6yOA7BKfqXsG1CZVIgrvkUX LTQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Z47OQtnP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a65680d000000b005577100c574si265420pgt.698.2023.06.23.14.43.32; Fri, 23 Jun 2023 14:43:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Z47OQtnP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232922AbjFWVQW (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232870AbjFWVPd (ORCPT ); Fri, 23 Jun 2023 17:15:33 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 379B2270A; Fri, 23 Jun 2023 14:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jammjAxbCgbnRHLqhi6UIftAryvqKnOHjwdJrbKzjag=; b=Z47OQtnPiaEB5oaBB+oz82Qsg6BtHw8YihUVIhQDCMR+I0tQpbbrpJXq nj5C0YQSxjWsFlY9SUmJShUU8xGXEqdHAlNbU+0vzr8txprHO2a1l78O0 vJXXUrP7E3H3oTBJf1CDCM1QC0nZjMpj3m7aYP6mcSPVWR15IxWF2hFkG o=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,153,1684792800"; d="scan'208";a="59686178" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:13 +0200 From: Julia Lawall To: Zack Rusin Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, VMware Graphics Reviewers , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/26] drm/vmwgfx: use array_size Date: Fri, 23 Jun 2023 23:14:51 +0200 Message-Id: <20230623211457.102544-21-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall --- drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c b/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c index 829df395c2ed..c72fc8111a11 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c @@ -88,7 +88,7 @@ int vmw_devcaps_create(struct vmw_private *vmw) uint32_t i; if (gb_objects) { - vmw->devcaps = vzalloc(sizeof(uint32_t) * SVGA3D_DEVCAP_MAX); + vmw->devcaps = vzalloc(array_size(SVGA3D_DEVCAP_MAX, sizeof(uint32_t))); if (!vmw->devcaps) return -ENOMEM; for (i = 0; i < SVGA3D_DEVCAP_MAX; ++i) {