Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2671547pxb; Mon, 11 Jan 2021 16:44:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRIjH59gV9aYKfuKoavdwqk2OadWXGaaB1FXAS79KmQyfUe2i2oBSe/OLnCqiOb6BSPq6J X-Received: by 2002:a05:6402:17a3:: with SMTP id j3mr1334006edy.333.1610412263777; Mon, 11 Jan 2021 16:44:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610412263; cv=none; d=google.com; s=arc-20160816; b=uaY2DwZDruIM/XGY0p6nz2mzXgHxQfFc7E7QHmrwSJ4Nx96WvKsXdX9KWBhevuwOcQ +blz8NFx9DzApwh3f4y45Ba1Muy88FduB7F3bUQmANEH23EwRmCVuAcstUGduT4oik4+ nKvJr8WOFwXvjJOL0v/Rf+PJ+1Xj3/qsPdiQ5uCkAg0Ssph3ddpYT3/8+2HCfY87V5L3 Uq+TLjWDPz4pFp22rO76tO2reYnveGoWSXqKxAS6GewIk951+nLCpFoZwlrdEZXFtM+m Rvp4lFMgba44KJiBnLQPviLGfNTfIq+kXXferFBQ0mes8kHXXjHRf2EdPFuCLr/jyVq7 RDvg== 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=HpNIGQhjXDcbn3Tscemoe+dyckP7inkK07Pb+JOKEfE=; b=GZAhpQQqtjLI5+lMmY3eL5HBl2tVFWg3DzdX6HkiD6bFNM+m4rElmsInTRyCB+2q44 txPGD2vpafhliKl5PrxKOIV5vVtq4eDODh0WQ9VNSPreZm22IeOyBW5obQaPYS4G8mF2 OMiNEAIdx0AZ2zpyGzolxhfSgITid3R1ObZk2d7rKhJdH9wYkI9S2W8UFRalPqsc9y3/ +Ab7XqAfoEx6nBvwgskUuIDT+DPcFD2/sGbLQSuDoIuAdpItCCo+T4mix75zMLilXmwC 8f3FGVpPkc20HFOF0bDBx6z3pvQYzt562PF4IQL5PfSR/g2Ju94k9w0U7pbWndzpRE7u cIdQ== 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 en21si449629ejc.393.2021.01.11.16.43.59; Mon, 11 Jan 2021 16:44:23 -0800 (PST) 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 S1727612AbhAKM5r (ORCPT + 99 others); Mon, 11 Jan 2021 07:57:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbhAKM5r (ORCPT ); Mon, 11 Jan 2021 07:57:47 -0500 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 A0864C061786 for ; Mon, 11 Jan 2021 04:57:06 -0800 (PST) Received: from ramsan.of.borg ([84.195.186.194]) by michel.telenet-ops.be with bizsmtp id FQx42400V4C55Sk06Qx4bv; Mon, 11 Jan 2021 13:57:05 +0100 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 1kywkp-002prj-TH; Mon, 11 Jan 2021 13:57:03 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1kywkp-001VrE-AU; Mon, 11 Jan 2021 13:57:03 +0100 From: Geert Uytterhoeven To: Andrzej Hajda , Neil Armstrong Cc: Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit Date: Mon, 11 Jan 2021 13:57:02 +0100 Message-Id: <20210111125702.360745-1-geert+renesas@glider.be> 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. While 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 may start to happen when the driver is reused for a 32-bit SoC, or when code is copied for a new driver. Signed-off-by: Geert Uytterhoeven --- Compile-tested only. --- 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 66b67402f1acd57d..a8da3081efdcc84e 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -195,7 +195,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