From patchwork Mon Jul 17 06:22:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Hui X-Patchwork-Id: 13315229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A1A9EB64DC for ; Mon, 17 Jul 2023 06:23:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A7D810E1D8; Mon, 17 Jul 2023 06:23:06 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by gabe.freedesktop.org (Postfix) with SMTP id AFF8110E1D8 for ; Mon, 17 Jul 2023 06:23:03 +0000 (UTC) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 391F260198854; Mon, 17 Jul 2023 14:22:45 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, airlied@gmail.com, daniel@ffwll.ch, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com Subject: [PATCH] drm/i915/tv: avoid possible division by zero Date: Mon, 17 Jul 2023 14:22:10 +0800 Message-Id: <20230717062209.124106-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Su Hui , intel-gfx@lists.freedesktop.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, mripard@kernel.org, andrzej.hajda@intel.com, ankit.k.nautiyal@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Clang warning: drivers/gpu/drm/i915/display/intel_tv.c: line 991, column 22 Division by zero. Assuming tv_mode->oversample=1 and (!tv_mode->progressive)=1, then division by zero will happen. Fixes: 1bba5543e4fe ("drm/i915: Fix TV encoder clock computation") Signed-off-by: Su Hui --- drivers/gpu/drm/i915/display/intel_tv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c index 36b479b46b60..82b54af51f23 100644 --- a/drivers/gpu/drm/i915/display/intel_tv.c +++ b/drivers/gpu/drm/i915/display/intel_tv.c @@ -988,7 +988,8 @@ intel_tv_mode_to_mode(struct drm_display_mode *mode, const struct tv_mode *tv_mode, int clock) { - mode->clock = clock / (tv_mode->oversample >> !tv_mode->progressive); + mode->clock = clock / (tv_mode->oversample != 1 ? + tv_mode->oversample >> !tv_mode->progressive : 1); /* * tv_mode horizontal timings: