Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13036273rwd; Fri, 23 Jun 2023 14:44:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/1vXRLPTxGIMDm1HuDjyoe4Ej6TbUTtnKScUtc0kGxL6LEqzMlubkUpEZo0yMwFJWdaum X-Received: by 2002:a05:6a00:b51:b0:668:71a1:2e74 with SMTP id p17-20020a056a000b5100b0066871a12e74mr14531618pfo.5.1687556644303; Fri, 23 Jun 2023 14:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556644; cv=none; d=google.com; s=arc-20160816; b=cbvNolndrv8y67BdfIKLCuFudoeOAYfi6XoivCJn22GEIvetT04jPaV8doDRPjv3ut u1Zcdm27qsYLuZeEBjfBbOKf1Rc9akd/nyi/+rW4+YiiHkI7XW4zkoxpL6kkUw8qLOIo k/m1le0wUTN0QywV5Z88VFUMTL9jhppt/d3erC7HAACG4zmusOJcHPvsLZeHPk1xMdHa 2fkn1y98zGy+X2jRzA5WKonkwA5FCTuo/YeoE0r1MPbogIRI7FsfnTJGGg71qM881MxO Y5C27IxKxxH7iB34242I6LrcNguezOwH9O73fKkpLgOuJ2NDbGegUmWYaupuw65kC0kT t+3A== 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=P1v6BJpujkRR/XkZZ2TcSC10Ee0xBDh3V/U/H44vDYA=; fh=wiRZAUBhqKiWWd/HTa1epr+0ZBHJz5POkOeTBY45oXQ=; b=ENI5KmR7JdEjYKgjfLx1A7DjPBz8vnJleWQP5s7rdbgW9uimXZKznbL2CYNMUaWJFu 5Vv199Tr4IX3e/O0Qo3Se5+kHIQ8IwLB4lRE2wPD5Y0J21Qi3XpsZdgJ7IAZUE4v1aC7 mGAX/poWfaIA7Oh/NkZ97ia/P9d33Xziy0/Z4nLOqKC/TuZKnPae83K/V3kPoz05pOJ6 c2GIbYtQPbPWpCclevsdG9QldPzhsb2YnJ0ryRSt2GAvMZSaNncmfZBBIPmrSI0itMa2 9fakPv4BaCznKkAY8ckVtoQMQqWlOB8aCuQ3OAqWbOJXvAJVJYTyuZjvJFfy7+ZER0DP sp+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=bZVjS8wA; 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 s23-20020a056a00179700b006432e1ea8e4si92663pfg.14.2023.06.23.14.43.52; Fri, 23 Jun 2023 14:44:04 -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=bZVjS8wA; 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 S232457AbjFWVPR (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231802AbjFWVPO (ORCPT ); Fri, 23 Jun 2023 17:15:14 -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 54677E65; Fri, 23 Jun 2023 14:15:13 -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=P1v6BJpujkRR/XkZZ2TcSC10Ee0xBDh3V/U/H44vDYA=; b=bZVjS8wAqRR6iyNa9gnoxPEfrIs2w7LvzRNlQSyygW9EHkgELuwGdiCI Y4w81WWcTQErSQ9Y2Mw6GBxoIfzicPKsH4u6eQxEzmdmBcgWgeGnZciAb ArLbVrFlB+O8EJ8HQdjVyipEMZiXaQ6itAc4jEyAgyCT/aRqz/x7K2K5a E=; 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="59686161" 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:10 +0200 From: Julia Lawall To: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/26] drm/gud: use array_size Date: Fri, 23 Jun 2023 23:14:34 +0200 Message-Id: <20230623211457.102544-4-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: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/gpu/drm/gud/gud_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c index dc16a92625d4..34df847bd829 100644 --- a/drivers/gpu/drm/gud/gud_pipe.c +++ b/drivers/gpu/drm/gud/gud_pipe.c @@ -390,7 +390,7 @@ static int gud_fb_queue_damage(struct gud_device *gdrm, struct drm_framebuffer * mutex_lock(&gdrm->damage_lock); if (!gdrm->shadow_buf) { - gdrm->shadow_buf = vzalloc(fb->pitches[0] * fb->height); + gdrm->shadow_buf = vzalloc(array_size(fb->pitches[0], fb->height)); if (!gdrm->shadow_buf) { mutex_unlock(&gdrm->damage_lock); return -ENOMEM;