From f8313c4359699ce4cd36f3caec2adfd4ee59a34a Mon Sep 17 00:00:00 2001 From: riastradh Date: Tue, 13 Sep 2022 09:47:17 +0000 Subject: usbdi(9): Rule out possible race to read xfer->ux_status. I think this might actually be safe, because when it's synchronous, the xfer can't be reused except by the caller after usbd_transfer returns. But let's make it definitely not wrong instead of maybe actually safe. --- sys/dev/usb/usbdi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 5730925ea5f..841249e6d9f 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.244 2022/09/07 10:41:34 riastradh Exp $ */ +/* $NetBSD: usbdi.c,v 1.245 2022/09/13 09:47:17 riastradh Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.244 2022/09/07 10:41:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.245 2022/09/13 09:47:17 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -501,10 +501,10 @@ usbd_transfer(struct usbd_xfer *xfer) break; } } - SDT_PROBE2(usb, device, xfer, done, xfer, xfer->ux_status); - /* XXX Race to read xfer->ux_status? */ + err = xfer->ux_status; + SDT_PROBE2(usb, device, xfer, done, xfer, err); usbd_unlock_pipe(pipe); - return xfer->ux_status; + return err; } /* Like usbd_transfer(), but waits for completion. */ -- cgit