Skip to contentSkip to conversation

firewire: cdev: Check return value in ioctl_get_cycle_timer()

PATCH Applied Sreeraj S Kurup 2 participants 3 messages Oct 29 – Nov 2 Firewire

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firewire: cdev: Check return value in ioctl_get_cycle_timer()

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.

---
 drivers/firewire/core-cdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firewire/core-cdev.c +4 -1
index 87efd65e6b00..76606c37d212 100644
@@ -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;
Signature · 1 line
2.55.0
maintainer Applied
#1 lore raw

Hi,

Quoted 11 lines · Sreeraj S Kurup

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.

---
 drivers/firewire/core-cdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Applied to for-next branch.

I prefer this submission to the previous ones from other contributors[1]. It's concise, to the point, and easy to read. When using generative AI in our work, it's especially important to keep the intended recipients in mind.

[1] https://lore.kernel.org/lkml/[email protected]/

Thanks

Takashi Sakamoto

#2 lore raw

Hi Takashi,

Thanks for applying the patch!

Best regards,
Sreeraj