public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] drm/amd/ras: Fix memory corruption in ras_core_convert_timestamp_to_time()
@ 2025-10-22 11:04 Dan Carpenter
  2025-10-23  7:18 ` kernel test robot
  2025-10-23 19:38 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-10-22 11:04 UTC (permalink / raw)
  To: YiPeng Chai
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Tao Zhou, Hawking Zhang, amd-gfx, dri-devel, linux-kernel,
	kernel-janitors

The div64_u64_rem() function takes a u64 as a remainder.  Passing an int
pointer to it will result in memory corruption.  Change
"remaining_seconds" from int to u64.

Fixes: ace232eff50e ("drm/amdgpu: Add ras module files into amdgpu")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/amd/ras/rascore/ras_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_core.c b/drivers/gpu/drm/amd/ras/rascore/ras_core.c
index 01122b55c98a..d8a004878a64 100644
--- a/drivers/gpu/drm/amd/ras/rascore/ras_core.c
+++ b/drivers/gpu/drm/amd/ras/rascore/ras_core.c
@@ -67,9 +67,10 @@ int ras_core_convert_timestamp_to_time(struct ras_core_context *ras_core,
 	int seconds_per_day = 24 * 60 * 60;
 	int seconds_per_hour = 60 * 60;
 	int seconds_per_minute = 60;
-	int days, remaining_seconds;
+	uint64_t remaining_seconds;
+	int days;
 
-	days = div64_u64_rem(timestamp, seconds_per_day, (uint64_t *)&remaining_seconds);
+	days = div64_u64_rem(timestamp, seconds_per_day, &remaining_seconds);
 
 	/* utc_timestamp follows the Unix epoch */
 	year = 1970;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-23 19:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 11:04 [PATCH next] drm/amd/ras: Fix memory corruption in ras_core_convert_timestamp_to_time() Dan Carpenter
2025-10-23  7:18 ` kernel test robot
2025-10-23 19:38 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox