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=1796383674; b=hHCH8z5xCUrStK4Tkrg6Vc1P28k1pC3P27DEp6Ur4vbySTNeteUjEkDJsgYQ+l9Y49bE kIT6i9diMk37vY6gZ60/BLnGukODvc6JAesU+fQmd29jAm/IJ1K6eyjnF8YsLjAOgNwvQ CLOGM659FZpjo6kY3y0dtEf1jkZJLXa4u7vOgz0k5fC9FzTo1Hqn3+8tI+Yc37sch1dcZ NyaEgy3wzOPXNPu6fleBMN7Aw8GjkqJcBICngyn/nZt1FqT89FfzJV9hq3wO4gwwHE/4z xuX0L4C+0OMYSj+hNnCrXzVSYKoWe3ReN8YaNUpEYbMxGQBLn58clt3/9Zj78MbcXoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383674; 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=Uf+MvsFAndNNhCuOAynj5jcBToQmZPsPqz1D76qBLfQ=; b=bRyokyTJyepFC3Zjovav+uCbjTVAdTQr4uOETh0CWnRmOkNsKq6L1VBZOPrn3MZ/qkKO /ocrxEBswpEOM9tFEMt79UFOFUOghFTfilH0lU2IvyPWMgIaBWOYBzuz6s580QPa4FU1H sfFevyMsYPiOMqKe4W668MizGhDJeF/LwqTBZL43GcbU201U0Nt2RBsl946nzD+8zOfZ8 DU17dOsyrTiTVyo/3dL4EiPQVb/POGY/UVkhSX1JWnWIhHecdHVO+Hgaz0zj4Vk0MGFo9 DExMZLrUleCcV4Ask4tEzQAsB8eRj/tOkC6WpSVcSJvnn4rEr5KE3oy9bJB8giclUvA== 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=M+TOXXQr; 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 A5A8C606A32C; Fri, 4 Dec 2026 11:27:54 +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=M+TOXXQr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FC801F000C2; Fri, 4 Dec 2026 11:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383674; bh=Uf+MvsFAndNNhCuOAynj5jcBToQmZPsPqz1D76qBLfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M+TOXXQrMU5ijKk73nL3mtxJ/uTGfPHreUrsdieOOyIoCOXplxEWbhSzXZTeHsrgD o1XFnhYBS8dMXjpdzEk9GbDNQiP2cDbeW+DRd5Jrp5KgzoCIoOzpNTuhLt6cUGosTD 5j/Ope4Yqk6pmRK+dHTQvfCjt0wdEuLxhpQdsCQ8= 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 6.12 321/555] drm/gud: avoid divide error in gud_stats_debugfs Date: Fri, 4 Dec 2026 19:06:04 +0900 Message-ID: <20261204100621.817064995@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 @@ -343,10 +343,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); }