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=1796386549; b=ZNbieYAJKj+ny+LqOEZTfF0EL1bFDlVOYmKkHnJ+1nwNxp9QkPPt25BmAwmpwMNSQzGU p3XEvrUpk97MISJuMSuAUexQZGu4UCp5fo04kpp943FUqTOPf8iwOqA06GkZtWFRJDWkO YdvAjLEp9R5S2+RzhZ+1GOFlfdsA25BbsSJ/1Iw6Re7fDIKppLN1AxDXHIHj4L3r410Sx fy7MvBweobcFrxJX1XOz+mhJ72Fn1SL2X6Fv27LmTlMiBQqD2xOEoocuXZDN9hkGfYSkd QhKBy9u3cYfYZ5ydD3ogt+KNJZjjDrGcKNnnzjMXJ6k+ZDh6MXYPLdtfQhrp94sCTBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386549; 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=fIOssVF3YjNqFky6ZrtTiQQGh/5cVshanW+LORvJJ7E=; b=dQafBq3o6T3NE/MIaIo4KlFCqaMlNN0rMRwfKJWLc1kciFQ6CKhQr2kUwm6AzY2XQWs0 sWcIQG8KkKWoHpLnuipsobMnf7f0rm7lSGvSp+1UKcfWxhhqgVChaH3gJQPYuswsjXK5u +jijWpG7FIkBphjPjNhdWbJI9mmRi6UW8Gce6Q+FKmwFi5ToRlwMR2zpWa+KFpIsD+bae ztu5zbD5uRlXHZLRdacdWC0HChtxUosNI8+hM01tNUYoxybjLP7FVTBTtejSponajO13J 09p0TMFRHVLtNR+jir99EB2iWkQNcpOffyhvh4mVY2tVpUrFzJSRhoU5tQ3D5unCyaw== 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=pJSToQvM; 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 B3B8D606A322; Fri, 4 Dec 2026 12:15:49 +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=pJSToQvM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5801F000C2; Fri, 4 Dec 2026 12:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386549; bh=fIOssVF3YjNqFky6ZrtTiQQGh/5cVshanW+LORvJJ7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pJSToQvMEZ32DupBlFgwcVwqDtJbDS3rSeyCR2/Diw11K3WadphIfCX04QPzzO1wk xg+LO/klX+9y7xfABavqbMFC09EA4/WfDhHOapom6AdFnKY3kUacBQkBgPlNh3puZ0 7TkgDmZByMI6sZlzy2y1jsgzFt9T4keN/d4qRQyY= 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.6 0983/1167] drm/gud: avoid divide error in gud_stats_debugfs Date: Fri, 4 Dec 2026 19:06:50 +0900 Message-ID: <20261204100727.804509128@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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 6.6-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); }