From patchwork Fri Jun 23 21:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053872vqr; Fri, 23 Jun 2023 14:38:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66QhsTLxvQgSe7eavDmwdT27nSlv0n05a7Y37FtmoRjpEtuPopJ0u6wcSDEKgk7gxWWqVR X-Received: by 2002:a05:6a21:788e:b0:125:b0ec:78be with SMTP id bf14-20020a056a21788e00b00125b0ec78bemr4360513pzc.10.1687556283535; Fri, 23 Jun 2023 14:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556283; cv=none; d=google.com; s=arc-20160816; b=PYjIZ1QwIpRG8EjVSWyt78slyrNqdLjidPPyGEGxJ3XK4PRQlCwiYPGxVRFdQcru5S 9EWVbU9SOkmDttWutc1IDIDviU7HDzWjDAb/WJyaaDrKsJqA/gng3CRBx2fU9OR32J1G Hovh92oPjclIF45/aoyQ68AsOW3nyMAM+virkbYe23O5CM+tRxyOzuXATSHls9KXeh6N n8owzC82zoA+Vy77Q5DMEwN+tuGQPZW0g5YeJClUxLvTa4bhSgR2PkB04hfRLDsLgxWx Kxxn9gQaPR/jpdzcT2TI1TPHbDyD2aQu+BYxhoWDI0uJ86yYjoObykhE0bXSxq5IQBq8 D3Pw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w136-20020a627b8e000000b006689f89b186si41985pfc.208.2023.06.23.14.37.51; Fri, 23 Jun 2023 14:38:03 -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 S232924AbjFWVQW (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531017477240211?= X-GMAIL-MSGID: =?utf-8?q?1769531017477240211?= 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) {