Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1557134pxb; Thu, 16 Sep 2021 09:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW0Ynd1O1soQ5zud5XxLgeG22Wlw+tTPxBTC1PNsAxU13YG6oJuLIRayB1HOtXuhYp9pcA X-Received: by 2002:a17:906:1e0c:: with SMTP id g12mr7466104ejj.155.1631811106177; Thu, 16 Sep 2021 09:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631811106; cv=none; d=google.com; s=arc-20160816; b=HgttbGD+l4BwDtncpXe1D1xvg5afKZldkG5NEJaeH7bMleGbn5rBdGXJqlBEXWhZaW lCr//EPAsp+CWkcBikaH+SWStlu+9nDqqJXmaub3DuwATXpgBof74m/J24g2cz4+xNyZ NqIiBCG/EKUm1Bz2WdqfjBDD2xpsJ8N5uqSB+EOUcXTTH0xp/aBfbkMgUdPdgEC0oL7w EHvI+A2d8g2cnMx7xhKXPlwPQ0oEM+YBwvb8+M8jZ1RJ5ifVBLc4WbbydWGOdL+ZjUsi PrIWTRo9j8H01NcPa0zI0aEjkSPq43edOdR7XrBLdIa8AalfBfQHBKJyFGQLLJYme5No ZM+w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GjXFcaF1HYyoUmH2nmZtT/m7bMouNBWPa5WyjLwI1dQ=; b=QIsmKacUHzOpoUdu8VbJ2o+1baj/yhJlTok2zwOW5ZMw913qQVHZaiml2xjjVrvJP6 qk2b8KMyoj4r2cZmSnMj4QtRmKLCepEOYoAlSNRzVvM5vnk9FizKobaIzifDLpxF9mXR bEx1djCPmVIulriQVcoZ/RkqyKVHTen5XS0VoE6L7hB43YK6vKBnQ9q82TfjjVdW3UUJ MgaK6WSsNAoT1wu/QspWxD2hiMReKRQPq+3OdWGl4J6ZV1Za3Wcu3OxVVEGQKl7pwsXH m8NUOae3K1wJC0lPBbRQzeZNd9UYvsuNvD46hd71T6BChIodrQz3nzPejL7Eq4ulSvlr xngQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cmY7+sfV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si1386863ede.227.2021.09.16.09.51.20; Thu, 16 Sep 2021 09:51:46 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cmY7+sfV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345032AbhIPQtd (ORCPT + 99 others); Thu, 16 Sep 2021 12:49:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:57406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344057AbhIPQoa (ORCPT ); Thu, 16 Sep 2021 12:44:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A918B61A55; Thu, 16 Sep 2021 16:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809543; bh=6dNN8OQPe/wsB34uoI/ICMKD2qSsK5yWqTj8ezysK4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmY7+sfVY2xy75hhNwMbo93rNIvArg5eDlj342+Dr8BiQcWwscc+UnYWi5//Z365g OsjaexZdazrGiw/BdGV1emiRbkK7slSwbiGEwZCjYtk5Z2J7Odex7LzDXQB+bpvIy4 cYjs/SRz902ed22MXDrsylYyralFtqStD6ETvdWA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Fabio Estevam , Laurent Pinchart , Sam Ravnborg , Sasha Levin Subject: [PATCH 5.13 193/380] drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit Date: Thu, 16 Sep 2021 17:59:10 +0200 Message-Id: <20210916155810.634706308@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven [ Upstream commit 47956bc86ee4e8530cac386a04f62a6095f7afbe ] 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 Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/ebb82941a86b4e35c4fcfb1ef5a5cfad7c1fceab.1626255956.git.geert+renesas@glider.be Signed-off-by: Sasha Levin --- 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 c65ca860712d..6cac2e58cd15 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.30.2