Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2827174pxv; Mon, 12 Jul 2021 02:56:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFTEn61qUENZTGbV72B4cKe5V81caSrUQYDFpfn3FBzXsszWBRBDSCDoYXB+W5DJysMcfQ X-Received: by 2002:a6b:b2c6:: with SMTP id b189mr12583291iof.50.1626083761472; Mon, 12 Jul 2021 02:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083761; cv=none; d=google.com; s=arc-20160816; b=ZWE2bnjEZJbtSjJoObJ7iuNOu1Aug0e9ezrASIeCU8mHxoYuQh5Do+5zwNZqgV/NwN ZLucGypCe4Cj9FP+JNMarO+LfLDZi/3r06tnUKCI80cwUqufPVJpcxyuvm6ZfklvjutU 7iKTHpp0CFWZj2ycoPPYGlsoiycS1c69Gn3D5kKgLYEDVz0TfASia34cGDMVrgaDXDo2 XmIS1io/6afTllRH232gDPqheB45fxIVRV8sDvJjJdD9Ty6tDgcQ1LNouIKJf4IAms2M aW+qkSADrRNV2zl6AzrNT7GydXQyQxgbArWSomvpSEEAKE/SWVWA2WF27AdtYyZUJZMP 2IIw== 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=K+FF+goQR298AYrRt2zKYCVcaDEmJBGvnESEOU3UGXU=; b=sYYu9WlDuonw7LJ+bAAP8Pc/zI1MVSJznekOmNuzeIeF0ewzCPz4SJflI4/THOMD3z qJ0LvrIeLCdEmux4CmIEiYOQhuMDca6mFSBKilzSthKd9ZfUbYiCG1zfv6Vb8Agk8dPD 0kSz9KLIhEu9+xjTia30WFDAWgmb+pXqYXeehOAUkn0Gy6OfGBpaiY46gFaB/bMAt2kA mA9rSSquyP/L5NOdXUw8Zgw2bS25+D9Ghc4xEbkTmc7Oy9ztpOxuAeO/vt1XmrTRejac Dw647G02IcE5K1N9O4e3XfeW/uZoLQ427E5Gn2tGPv7Uw/Dw7bKOCnuGatYJ3zVbdF/b tFwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gkVZXpO1; 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 a10si3529897ilv.72.2021.07.12.02.55.50; Mon, 12 Jul 2021 02:56:01 -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=gkVZXpO1; 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 S241824AbhGLG7b (ORCPT + 99 others); Mon, 12 Jul 2021 02:59:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:41504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238873AbhGLGoZ (ORCPT ); Mon, 12 Jul 2021 02:44:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E4F5610CA; Mon, 12 Jul 2021 06:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072016; bh=wyMWFanJk4V0p8E7UCLTYW9/FtAYpGWdH2tr4Hp7hEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkVZXpO15Fs8ySDy2iIaRq7M2IGfatXjx8HkpUCCii9WBFZDGIslZtDAaiqx2PDmW O1Ywi01zDrFLF/jSejsssJTh6rTb7BrpIDcRJezbKZc9VE+NdafLNcHpFJfSt3fKZd sbeiLWzQ7dND7R3N/DIVb9yKvgGCoo7wNeap/FZw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Guenter Roeck , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.10 318/593] drm/rockchip: cdn-dp: fix sign extension on an int multiply for a u64 result Date: Mon, 12 Jul 2021 08:07:58 +0200 Message-Id: <20210712060920.477908881@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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: Colin Ian King [ Upstream commit ce0cb93a5adb283f577cd4661f511047b5e39028 ] The variable bit_per_pix is a u8 and is promoted in the multiplication to an int type and then sign extended to a u64. If the result of the int multiplication is greater than 0x7fffffff then the upper 32 bits will be set to 1 as a result of the sign extension. Avoid this by casting tu_size_reg to u64 to avoid sign extension and also a potential overflow. Fixes: 1a0f7ed3abe2 ("drm/rockchip: cdn-dp: add cdn DP support for rk3399") Signed-off-by: Colin Ian King Reviewed-by: Guenter Roeck Signed-off-by: Heiko Stuebner Link: https://patchwork.freedesktop.org/patch/msgid/20200915162049.36434-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/rockchip/cdn-dp-reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.c b/drivers/gpu/drm/rockchip/cdn-dp-reg.c index 9d2163ef4d6e..33fb4d05c506 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.c @@ -658,7 +658,7 @@ int cdn_dp_config_video(struct cdn_dp_device *dp) */ do { tu_size_reg += 2; - symbol = tu_size_reg * mode->clock * bit_per_pix; + symbol = (u64)tu_size_reg * mode->clock * bit_per_pix; do_div(symbol, dp->max_lanes * link_rate * 8); rem = do_div(symbol, 1000); if (tu_size_reg > 64) { -- 2.30.2