From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380586; b=Fk1LErCKaOBe72eIB5NkhtN50RV4Y1xEex7xQibRLuqAIS1s+zsaB0o2RAAzyp4kIk83 fvahUBvOS+zl2LHqap+CrR/ck/HQHhcmCtfOVQvoBsxI6hLKyDtAdI/7AWct4NktKElKT nA+fWB7zMTU4ETNjDGio/UCedVVX8HMYxG6feqbpg/FB/U9pknwpH7pOaYm0kuuaiDBDk BLwYuuQSCTv4wiRiTXc/Fv2GT3G1na/olrFozbf6/KfWG3azM53beiVIf8zD4c04GcjMr y78PpKZWGLl88/pkt3BN4ZeJ6xngnhxYiWmxFNfoZdsVBs66Irsa9FdEhINZRTidbBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380586; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=RX0UYRnB0ljnzb8Jhg+uvyvX1aO4u+CKUEpIdorFda0=; b=qDVtHmtHDzCt1sPpvvBi6HmyRgqPEL8FtCuvovxlFhJbtoYv//GPjKGhYvQa26aMUKUM Est08OENvOtL1Q6l2K0TqiXexpnL2LA0gEvki2MNcZ7Sry8fTXLhtPlue3oIOIF5VUbgr AtJGYpzpuPOqvtV0GwhBiBbxR4VDsZOD5iTAHbYJB/OD8Zm5G0qau80YZk4JIHxg91DRD UmXHX+9jFsuYzNZStmZatmyPjEjYrU5SJ6z91iBkKlMri0MDOEpJWa44Ussf5WrTQ1HH8 w0FxC/J8MXPKrspX3FSabJcoP+3/uj/L6ubniti5v+39nWyCvnDzGjcVH18bj5aLmWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="j/k62ODa"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77E23606A680; Fri, 4 Dec 2026 10:36:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j/k62ODa Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A741F000CE; Fri, 4 Dec 2026 10:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380586; bh=RX0UYRnB0ljnzb8Jhg+uvyvX1aO4u+CKUEpIdorFda0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j/k62ODa62jbEpIUGoAkSqI5UFyfICb0HxgNxHBtDMohAxnY+H8M9hYleVbSoF/Tv wgpNOFx2+GMkiSVIaxz6wquW0clN13xttuQJgG7ijBV5NcqC2YL97c3itov3P+Wvik sMvAlOXRoI5an+yEQQRaGaw3Rq6f0TMYa+3xy4ic= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bin Yu , Cheng Wen , YuanZhe Liu <25031212351@stu.xidian.edu.cn>, Ruben Wauters Subject: [PATCH 7.3 337/742] drm/gud: avoid divide error in gud_stats_debugfs Date: Fri, 4 Dec 2026 19:03:21 +0900 Message-ID: <20261204100644.002890840@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: YuanZhe Liu <25031212351@stu.xidian.edu.cn> commit 431c2dffd2b7c1240a6e579f0c74104cd2e17329 upstream. gud_stats_debugfs() computes the compression ratio by dividing the accumulated uncompressed length by stats_actual_length. That counter is zero until the first framebuffer flush has completed, so reading the stats debugfs file on a display which negotiates LZ4 compression raises a divide error before any frame has been sent. The wrap-around reset in gud_flush_rect() also clears the counter for a moment, which a concurrent read can observe. Copy the counter into a local variable and skip the ratio computation when it is zero. Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu Signed-off-by: Bin Yu Co-developed-by: Cheng Wen Signed-off-by: Cheng Wen Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> Acked-by: Ruben Wauters Link: https://patch.msgid.link/20261029073311.14556-1-25031212351@stu.xidian.edu.cn Signed-off-by: Ruben Wauters Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/gud/gud_drv.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/gud/gud_drv.c +++ b/drivers/gpu/drm/gud/gud_drv.c @@ -329,10 +329,17 @@ static int gud_stats_debugfs(struct seq_ seq_puts(m, "\n"); if (gdrm->compression) { + u64 actual_length = gdrm->stats_actual_length; u64 remainder; - u64 ratio = div64_u64_rem(gdrm->stats_length, gdrm->stats_actual_length, - &remainder); - u64 ratio_frac = div64_u64(remainder * 10, gdrm->stats_actual_length); + u64 ratio, ratio_frac; + + if (!actual_length) { + seq_puts(m, "Compression ratio: n/a\n"); + return 0; + } + + ratio = div64_u64_rem(gdrm->stats_length, actual_length, &remainder); + ratio_frac = div64_u64(remainder * 10, actual_length); seq_printf(m, "Compression ratio: %llu.%llu\n", ratio, ratio_frac); }