summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2020-04-03 12:27:55 +0000
committermartin <martin@NetBSD.org>2020-04-03 12:27:55 +0000
commitbb70f8d0ffabc510091fc52e9213108d43c1cdd6 (patch)
tree5a2f971895120cc69580313d75803ce9310d36e2 /sys
parenta26f8262dc64a008715d3b26b6cb1a874f968962 (diff)
Pull up following revision(s) (requested by skrll in ticket #819):
sys/dev/usb/usbdi.c: revision 1.199 Avoid crashes if we fail to allocate a transfer buffer and avoid an unnecessary usbd_free_buffer before usbd_free_xfer Worked out by Riastradh
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/usbdi.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index acfb2ae514a..120755c67d2 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.182.4.3 2020/03/01 12:35:16 martin Exp $ */
+/* $NetBSD: usbdi.c,v 1.182.4.4 2020/04/03 12:27:55 martin 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.182.4.3 2020/03/01 12:35:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.182.4.4 2020/04/03 12:27:55 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -523,6 +523,11 @@ usbd_create_xfer(struct usbd_pipe *pipe, size_t len, unsigned int flags,
if (xfer == NULL)
return ENOMEM;
+ xfer->ux_pipe = pipe;
+ xfer->ux_flags = flags;
+ xfer->ux_nframes = nframes;
+ xfer->ux_methods = pipe->up_methods;
+
if (len) {
buf = usbd_alloc_buffer(xfer, len);
if (!buf) {
@@ -530,16 +535,10 @@ usbd_create_xfer(struct usbd_pipe *pipe, size_t len, unsigned int flags,
return ENOMEM;
}
}
- xfer->ux_pipe = pipe;
- xfer->ux_flags = flags;
- xfer->ux_nframes = nframes;
- xfer->ux_methods = pipe->up_methods;
if (xfer->ux_methods->upm_init) {
int err = xfer->ux_methods->upm_init(xfer);
if (err) {
- if (buf)
- usbd_free_buffer(xfer);
usbd_free_xfer(xfer);
return err;
}