Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp235323pxv; Wed, 14 Jul 2021 02:49:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwppgC5RzwkOw2pDSYr5zDSElixKg6+fMwk+rQfK+/cEK11xNJhs0S1NUjiPpp8d0KA1h4z X-Received: by 2002:a17:907:4cf:: with SMTP id vz15mr11293379ejb.161.1626256169346; Wed, 14 Jul 2021 02:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626256169; cv=none; d=google.com; s=arc-20160816; b=EPlUZC/pfXl4FbvBWEXVHvnkR8GizzREFKO/uDlQ4cQ+nG/kvNUFmztyR800boL9Bc OkGpHw+q0qLV53qAyh0zoU+s7bsQ6qVRIZiFm3why7bMT8mmJA5YuPDQjWlM9HNDVn5r c1UWYuLvtn9/ilLe9dvQ01dyOaXYHqBqb7Y/bkqn53qUhtHOJE+UL6W2BlU6RaRm3EpI 4mbtZSdOiNlrxeme80gdjlOpRzxiBTfFXZZZtWAV6VcTdfoiN6MVmYjmkFz53Yr57GzP 2klgImjgvbbDSsbjvkZ/6Tquv4V7M9hntp5LT+ekU2DD+u0YuVucZzX4Z8QLPhut4Ys3 NPhA== 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 :message-id:date:subject:cc:to:from; bh=odzZ+fVwWgUs8uZXX1C3dmMH6ribiv6S+GNWE/Joxn8=; b=x6qiMOvd1SzkD/QWWItQk8JBXEWx/lb4DuyhHXRNb5w0BzX5nkLmA/SPgYaBQSnyzb b+LKJgvjOqCS1BmKqprLmMv8JBeVOgmlAcdja3bzd2guffqkchKD2mQBEwZVq9hHaIHl P2cg8eG4Q5iyuqI1w8MtVMakNe07wACfIJQ9G/pJOxwCvjcgYnLvWk6dm/wuIksZp81Z NILjBmGd8ygTvQ5vZbTCsVvNBviS0cTDdpFZcyVPEgLFQI8G2kZFYeU0Bny4AIrwgIp3 FW4eFDU9wuE1HLifevQKWUlhHlBwXmH87fZXMdWC87VGCJHzgy7+WSxNeOpLWjKAtUfZ v5Iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si1995804edr.438.2021.07.14.02.49.05; Wed, 14 Jul 2021 02:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238679AbhGNJvG (ORCPT + 99 others); Wed, 14 Jul 2021 05:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238337AbhGNJvF (ORCPT ); Wed, 14 Jul 2021 05:51:05 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF63C06175F for ; Wed, 14 Jul 2021 02:48:13 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:39cc:190a:2775:cfe7]) by michel.telenet-ops.be with bizsmtp id Uxo82500J1ccfby06xo8ct; Wed, 14 Jul 2021 11:48:12 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1m3bUu-0015hM-FF; Wed, 14 Jul 2021 11:48:08 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1m3bUu-00A3Yx-0R; Wed, 14 Jul 2021 11:48:08 +0200 From: Geert Uytterhoeven To: Andrzej Hajda , Neil Armstrong , Robert Foss , David Airlie , Daniel Vetter Cc: Laurent Pinchart , Jonas Karlman , Jernej Skrabec , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Fabio Estevam , Laurent Pinchart Subject: [PATCH v2] drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit Date: Wed, 14 Jul 2021 11:48:06 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As nwl_dsi.lanes is u32, and NSEC_PER_SEC is 1000000000L, the second multiplication in dsi->lanes * 8 * NSEC_PER_SEC will overflow on a 32-bit platform. Fix this by making the constant unsigned long long, forcing 64-bit arithmetic. As iMX8 is arm64, this driver is currently used on 64-bit platforms only, where long is 64-bit, so this cannot happen. But the issue will start to happen when the driver is reused for a 32-bit SoC (e.g. i.MX7ULP), or when code is copied for a new driver. Signed-off-by: Geert Uytterhoeven Reviewed-by: Fabio Estevam Reviewed-by: Laurent Pinchart --- Compile-tested only. v2: - Add Reviewed-by, - Add reference to i.MX7ULP. --- drivers/gpu/drm/bridge/nwl-dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c index 873995f0a7416e58..6002404ffcb9df08 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -196,7 +196,7 @@ static u32 ps2bc(struct nwl_dsi *dsi, unsigned long long ps) u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); return DIV64_U64_ROUND_UP(ps * dsi->mode.clock * bpp, - dsi->lanes * 8 * NSEC_PER_SEC); + dsi->lanes * 8ULL * NSEC_PER_SEC); } /* -- 2.25.1