Commit 0cb54a3e authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

USB: debugging code shouldn't alter control flow

People have complained that debugging code shouldn't alter the flow of
control; it should restrict itself to printing out warnings and error
messages.  Bowing to popular opinion, this patch (as1518) changes the
debugging checks in usb_submit_urb() to follow this guideline.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Reported-by: default avatarKeith Packard <keithp@keithp.com>
CC: Pavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c39c654f
...@@ -403,20 +403,17 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) ...@@ -403,20 +403,17 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
* cause problems in HCDs if they get it wrong. * cause problems in HCDs if they get it wrong.
*/ */
{ {
unsigned int orig_flags = urb->transfer_flags;
unsigned int allowed; unsigned int allowed;
static int pipetypes[4] = { static int pipetypes[4] = {
PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
}; };
/* Check that the pipe's type matches the endpoint's type */ /* Check that the pipe's type matches the endpoint's type */
if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) { if (usb_pipetype(urb->pipe) != pipetypes[xfertype])
dev_err(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
usb_pipetype(urb->pipe), pipetypes[xfertype]); usb_pipetype(urb->pipe), pipetypes[xfertype]);
return -EPIPE; /* The most suitable error code :-) */
}
/* enforce simple/standard policy */ /* Check against a simple/standard policy */
allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK |
URB_FREE_BUFFER); URB_FREE_BUFFER);
switch (xfertype) { switch (xfertype) {
...@@ -435,14 +432,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) ...@@ -435,14 +432,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
allowed |= URB_ISO_ASAP; allowed |= URB_ISO_ASAP;
break; break;
} }
urb->transfer_flags &= allowed; allowed &= urb->transfer_flags;
/* fail if submitter gave bogus flags */ /* warn if submitter gave bogus flags */
if (urb->transfer_flags != orig_flags) { if (allowed != urb->transfer_flags)
dev_err(&dev->dev, "BOGUS urb flags, %x --> %x\n", dev_WARN(&dev->dev, "BOGUS urb flags, %x --> %x\n",
orig_flags, urb->transfer_flags); urb->transfer_flags, allowed);
return -EINVAL;
}
} }
#endif #endif
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment