Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb usbdi(9): Rule out possible race to read xfer->u...



details:   https://anonhg.NetBSD.org/src/rev/4d9fc863a836
branches:  trunk
changeset: 370045:4d9fc863a836
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Sep 13 09:47:17 2022 +0000

description:
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.

diffstat:

 sys/dev/usb/usbdi.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (32 lines):

diff -r 8515692dca6e -r 4d9fc863a836 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Tue Sep 13 09:45:36 2022 +0000
+++ b/sys/dev/usb/usbdi.c       Tue Sep 13 09:47:17 2022 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
                        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. */



Home | Main Index | Thread Index | Old Index