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=1796382166; b=DPABgDU+n1iiFQebemsZ7o5QfWoK0M9ETb7o5XPDJxpUJpl8Odpvcspefnd1Yy+8dzjy ENfhY0RWGRFVF+eMLK7gRffcLiCS4nXZZE//UWelxDsf9M0iGCEaSWFGxwpAuJjqkSMex MMqB9/Emp3ctqFeLXoEuHihDr9F28hJw4FXwmneRQ6fMxCvU2Ju3UV2s+5lUYi1LedJ6R hRdfHduv/cVcLB+zsMjMlRjh4xvff2hQ9xnQ8ERE94mDlzUNrUi+oI4ZcjNvfg8ccrVX8 ZuIoOzJiJqNMSIo9Qnk/SbP4QbMmLLfVc/oPWltd+rQPaU18joQL9YcR9COoNf3Ddrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382166; 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=evBy9JHfLUNyytRW1tLBgO7Qo0UfhycQLqYfzATX9I4=; b=2bf3oh8CrUtiCWpYAGeqbU/0LnHYaTtkzg5g50JmZ61VreAYhL2n7Sd+wrsswJSzsUN0 9E3ll8wFpRHI0VJOzhps0h8qsf4U16Ix0c/B/X9KRG9ZWrG+oj9jYCGde+XvwRdnHtcgn FT5IWu4bNsNxQ2I2uqAcnqfKdQfOjDQ3Q67VAkUU3l73+B4e9D1rqLxVup9hxGKnws7q3 5jc/Jfymq1Dfmkls+su1MbniD0W1W2cqy+EOPtHzcBj6tu472O5rXH7fOSUiTvjjaclZv t3cy1EiSa81ksdQh16Ji3avXHGagjYmvlICR95Dy89cnBNxeDC5TXhrXcgUQdxowung== 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=slxa1732; 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 EAAF0606A322; Fri, 4 Dec 2026 11:02:45 +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=slxa1732 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E5491F000C2; Fri, 4 Dec 2026 11:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382165; bh=evBy9JHfLUNyytRW1tLBgO7Qo0UfhycQLqYfzATX9I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=slxa1732pHe2GGdq8QETzuIDaWBD2ZN0XqerH0v66pWlpYjFXr8uMoqF57iuxncG3 wyOmRA5tWJD7CyICd1FbQ0pUPBBiSd8a+fcJsm5B0/zqzB2jLtwbZPxleD78pxgurc RlR2SFo2AzYoJX36zYYPq9rh3V90h2ORr2zO4YWs= 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.18 337/703] drm/gud: avoid divide error in gud_stats_debugfs Date: Fri, 4 Dec 2026 19:03:56 +0900 Message-ID: <20261204100636.748833732@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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); }