Skip to contentSkip to conversation

USB: usbdevfs: restore warning for nonsensical flags

PATCH New Greg Kroah-Hartman 1 participant 1 message Sep 5, 2018 USB

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 2/2 USB: usbdevfs: restore warning for nonsensical flags

Quoted 14 lines · Oliver Neukum

If we filter flags before they reach the core we need to generate our own warnings.

Fixes 0cb54a3e47cb ("USB: debugging code shouldn't alter control flow")
---
 drivers/usb/core/devio.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/core/devio.c +0 -0
index 263dd2f309fb..244417d0dfd1 100644

drivers/usb/core/devio.c static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb · line 1703

Quoted 7 lines
drivers/usb/core/devio.c +4 -0
@@ -1697,6 +1697,11 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
 		u |= URB_NO_INTERRUPT;
 	as->urb->transfer_flags = u;
 
+	if (!allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
+		dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n");
+	if (!allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
+		dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n");

We should not make it trivial for userspace to spam the kernel log if at all possible. Returning an error is probably the better thing to do here, not just silently fix it up or ignore it.

thanks,

greg k-h