Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5462277rwe; Tue, 18 Apr 2023 07:12:56 -0700 (PDT) X-Google-Smtp-Source: AKy350Z8mGXQda5JKQshvkZGOupnvhJOWIm1sBRxFKe7RYXVbRiwa1DH79N3chNkuI9SZFMLPlR/ X-Received: by 2002:a17:902:e54f:b0:1a6:51a6:ca76 with SMTP id n15-20020a170902e54f00b001a651a6ca76mr2477045plf.11.1681827176337; Tue, 18 Apr 2023 07:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681827176; cv=none; d=google.com; s=arc-20160816; b=D1gAsJuoPE+EfczC7pFcCP/u6+MP7beH73roQDaQiLRto0bjdW+3QxbPjLjpVzxQMe B3CWAuUW11phGJM0dY/Ta2Fa0NDrGl9J9i8wOMjHuyGQrqJm1tqouURUpGWlY3Nnw5lk tyU0lUnEqGygu8RgoL0mu2pdfaSqxBYdQN4aNgkgL3BArIMDUUdlbbcBDZdQmL5qnUEK IqVOu+3lYzya6x0YkHlgaopxrC4q9W9tLM7YLvZ5YM1W+Bj4kFX2Ler7oeRuiau+Vidc jQWgniTvaF9jtPqkX8cZbxTqikc15LF3W+HN6+Ue/jaakWRrgBbIo7YV3ae7vp0ibkha VzJg== 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=vJIRAuVFGLKiWBIaNbkletoKIf8WmNJm5QqM+xK0N9A=; b=xIGCukYAxpwVIaftW2UGZv2p3LH/FhMpOvmglEwtbm9Gxlm/XCXET2TuzkRgCJIod0 0HwtnRPWMGPaiIfJnDlprhLrYtDkmK0z+Yh6l11870Cbvp0bYn7jMuudxRtv2onDzs59 Bp5wLHDLVB0PH+vY1W/wflw8gse1EcxZUNhXfqPyIHk8kFVvHhPWbuX2Rxf2YMRHxiLt BtfTUA/zMnpHBDc1EKnBPnIM2Eu5cd5nQCuXL0ERl+eamWoBnpQpfCQLg+J2aWG08jt4 ihryZCbkkt+3OF5clxRZK6RMdUUHPKNqqkrC4vA+yFnxEW0cE+1bb3PUiEa22Q7mhMEh TBNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a170902ebd200b001a63a34809asi14034952plg.351.2023.04.18.07.12.34; Tue, 18 Apr 2023 07:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbjDROEt (ORCPT + 99 others); Tue, 18 Apr 2023 10:04:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjDROEn (ORCPT ); Tue, 18 Apr 2023 10:04:43 -0400 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 930B613845 for ; Tue, 18 Apr 2023 07:04:39 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 18 Apr 2023 17:04:37 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 18 Apr 2023 17:04:37 +0300 From: Nikita Zhandarovich To: Jani Nikula CC: Nikita Zhandarovich , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , "Ankit Nautiyal" , Manasi Navare , Stanislav Lisovskiy , "Jason A. Donenfeld" , , , , Subject: [PATCH] drm/i915/dp: prevent potential div-by-zero Date: Tue, 18 Apr 2023 07:04:30 -0700 Message-ID: <20230418140430.69902-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org drm_dp_dsc_sink_max_slice_count() may return 0 if something goes wrong on the part of the DSC sink and its DPCD register. This null value may be later used as a divisor in intel_dsc_compute_params(), which will lead to an error. In the unlikely event that this issue occurs, fix it by testing the return value of drm_dp_dsc_sink_max_slice_count() against zero. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: a4a157777c80 ("drm/i915/dp: Compute DSC pipe config in atomic check") Signed-off-by: Nikita Zhandarovich --- drivers/gpu/drm/i915/display/intel_dp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 62cbab7402e9..c1825f8f885c 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -1533,6 +1533,11 @@ int intel_dp_dsc_compute_config(struct intel_dp *intel_dp, pipe_config->dsc.slice_count = drm_dp_dsc_sink_max_slice_count(intel_dp->dsc_dpcd, true); + if (!pipe_config->dsc.slice_count) { + drm_dbg_kms(&dev_priv->drm, "Unsupported Slice Count %d\n", + pipe_config->dsc.slice_count); + return -EINVAL; + } } else { u16 dsc_max_output_bpp = 0; u8 dsc_dp_slice_count; -- 2.25.1