From patchwork Fri Jun 23 21:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6055487vqr; Fri, 23 Jun 2023 14:42:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TTfreQ1mfVwRJy4wkopVUQJcZmfx21YbgtCImkfi/cfnfD4wBEPKjGJydJhPYpxxXblzZ X-Received: by 2002:a17:902:9f8f:b0:1b5:4bdd:6428 with SMTP id g15-20020a1709029f8f00b001b54bdd6428mr218479plq.67.1687556551636; Fri, 23 Jun 2023 14:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556551; cv=none; d=google.com; s=arc-20160816; b=n7nE7JMzYwOHmCrE0Qx0oLWKzOm+5DVV90LeRaCS7V5W3dvMNTO6wWGbMz974zmfS4 rGHxXGowWB28iU33JgT9pJ5lKZUps3miDRzMa/8/vXSjN/ljZslNnGniC4n/3PBhtO08 /GMDDUgwswFtJtVcsBIAh1ainYuQxrOmDfs9Dl9r+7vAqvHLx0CCBBkMSPLUeTUQLGU9 w1fzObn5zxLHRvESQdLvnKaMhjcs6jxaOSzrMNGDy5eAll0TShSi/0szv39n5CCzvfkd ae7l8siM1saqZLI2lNUfYtImzKf/xL4pVO/umLu+fwqy4nr+hI2ynOw79PudjgIh72VG nI1g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a170902b71300b001b66f00d40csi61416pls.351.2023.06.23.14.42.17; Fri, 23 Jun 2023 14:42:31 -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 S232076AbjFWVPS (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:18 -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_Tr=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 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?1769531298359588976?= X-GMAIL-MSGID: =?utf-8?q?1769531298359588976?= 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;