From a9d8b705cc8369d90b2bfcd9848eef10e0f0be11 Mon Sep 17 00:00:00 2001 From: Matias N Date: Tue, 26 Mar 2019 21:54:01 -0600 Subject: [PATCH] drivers/usbdev/cdcacm.c: This fixes a problem where the host sent a "get descriptor" message of type "standard" with a recipient of type "interface". Since the composite driver would only pass messages to the child interfaces when a message was not "standard", this message was not handled. I changed the condition so that the composite driver checks not only if this is a "standard" message but if it is also directed to the device. Otherwise, the handling is delegated to the children of the composite device. --- drivers/usbdev/composite.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/usbdev/composite.c b/drivers/usbdev/composite.c index 29ff68b31e..915700a983 100644 --- a/drivers/usbdev/composite.c +++ b/drivers/usbdev/composite.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbdev/composite.c * - * Copyright (C) 2012, 2016-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -500,6 +500,7 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, uint16_t len; bool dispatched = false; int ret = -EOPNOTSUPP; + uint8_t recipient; #ifdef CONFIG_DEBUG_FEATURES if (!driver || !dev || !dev->ep0 || !ctrl) @@ -534,7 +535,10 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, ctrl->type, ctrl->req, value, index, len); UNUSED(index); - if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD) + recipient = ctrl->type & USB_REQ_RECIPIENT_MASK; + + if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD && + recipient == USB_REQ_RECIPIENT_DEVICE) { /********************************************************************** * Standard Requests @@ -701,10 +705,9 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, ret = composite_msftdescriptor(priv, dev, ctrl, ctrlreq, &dispatched); } #endif - else + else if (recipient == USB_REQ_RECIPIENT_INTERFACE || + recipient == USB_REQ_RECIPIENT_ENDPOINT) { - uint8_t recipient; - /********************************************************************** * Non-Standard Class Requests **********************************************************************/ @@ -713,12 +716,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, * requests. */ - recipient = ctrl->type & USB_REQ_RECIPIENT_MASK; - if (recipient == USB_REQ_RECIPIENT_INTERFACE || recipient == USB_REQ_RECIPIENT_ENDPOINT) - { - ret = composite_classsetup(priv, dev, ctrl, dataout, outlen); - dispatched = true; - } + ret = composite_classsetup(priv, dev, ctrl, dataout, outlen); + dispatched = true; } /* Respond to the setup command if (1) data was returned, and (2) the