[PATCH] firewire: cdev: Check return value in ioctl_get_cycle_timer()
From: Sreeraj S Kurup
Date: Thu Oct 29 2026 - 06:17:40 EST
ioctl_get_cycle_timer() ignores the return value of
ioctl_get_cycle_timer2(). If the latter fails, the output fields
may remain uninitialized, causing the caller to use uninitialized
data when calculating local_time and assigning cycle_timer.
Check the return value and propagate the error to the caller.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
drivers/firewire/core-cdev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 87efd65e6b00..76606c37d212 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -1316,9 +1316,12 @@ static int ioctl_get_cycle_timer(struct client *client, union ioctl_arg *arg)
{
struct fw_cdev_get_cycle_timer *a = &arg->get_cycle_timer;
struct fw_cdev_get_cycle_timer2 ct2;
+ int ret;
ct2.clk_id = CLOCK_REALTIME;
- ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2);
+ ret = ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2);
+ if (ret < 0)
+ return ret;
a->local_time = ct2.tv_sec * USEC_PER_SEC + ct2.tv_nsec / NSEC_PER_USEC;
a->cycle_timer = ct2.cycle_timer;
--
2.55.0