drivers/usbdev/cdcacm.c: Fix memory leak of RX failsafe timer.

This commit is contained in:
Juha Niskanen
2019-10-08 08:01:30 -06:00
committed by Gregory Nutt
parent 83e458873f
commit b4f6a3a878
6 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -696,7 +696,7 @@ NOTES:
2. 2016-12-23: Test appears to be fully functional in the single CPU mode. 2. 2016-12-23: Test appears to be fully functional in the single CPU mode.
3. 2016-12-24: But when SMP is enabled, there is a consistent, repeatable 3. 2016-12-24: But when SMP is enabled, there is a consistent, repeatable
crash in the waitpid() test. At the time of the crash, there is crash in the waitpid() test. At the time of the crash, there is
extensive memory corruption and a user exception occurrs (cause=28). extensive memory corruption and a user exception occurs (cause=28).
Things to Do Things to Do
============ ============
+6 -5
View File
@@ -714,7 +714,7 @@ static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv)
/* cdcacm_recvpacket() will return OK if the entire packet was /* cdcacm_recvpacket() will return OK if the entire packet was
* successful buffered. In the case of RX buffer overrun, * successful buffered. In the case of RX buffer overrun,
* cdcacm_recvpacket() will return a failure (-ENOSPC) and will * cdcacm_recvpacket() will return a failure (-ENOSPC) and will
* set the req->offset field * set the req->offset field.
*/ */
ret = cdcacm_recvpacket(priv, rdcontainer); ret = cdcacm_recvpacket(priv, rdcontainer);
@@ -1350,7 +1350,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate all endpoints... the endpoints will not be functional /* Pre-allocate all endpoints... the endpoints will not be functional
* until the SET CONFIGURATION request is processed in cdcacm_setconfig. * until the SET CONFIGURATION request is processed in cdcacm_setconfig.
* This is done here because there may be calls to kmm_malloc and the SET * This is done here because there may be calls to kmm_malloc and the SET
* CONFIGURATION processing probably occurrs within interrupt handling * CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail. * logic where kmm_malloc calls will fail.
*/ */
@@ -3003,6 +3003,7 @@ int cdcacm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
return OK; return OK;
errout_with_class: errout_with_class:
wd_delete(priv->rxfailsafe);
kmm_free(alloc); kmm_free(alloc);
return ret; return ret;
} }
@@ -3055,11 +3056,9 @@ int cdcacm_initialize(int minor, FAR void **handle)
*/ */
devinfo.nendpoints = CDCACM_NUM_EPS; devinfo.nendpoints = CDCACM_NUM_EPS;
#ifndef CONFIG_CDCACM_COMPOSITE
devinfo.epno[CDCACM_EP_INTIN_IDX] = CONFIG_CDCACM_EPINTIN; devinfo.epno[CDCACM_EP_INTIN_IDX] = CONFIG_CDCACM_EPINTIN;
devinfo.epno[CDCACM_EP_BULKIN_IDX] = CONFIG_CDCACM_EPBULKIN; devinfo.epno[CDCACM_EP_BULKIN_IDX] = CONFIG_CDCACM_EPBULKIN;
devinfo.epno[CDCACM_EP_BULKOUT_IDX] = CONFIG_CDCACM_EPBULKOUT; devinfo.epno[CDCACM_EP_BULKOUT_IDX] = CONFIG_CDCACM_EPBULKOUT;
#endif
/* Get an instance of the serial driver class object */ /* Get an instance of the serial driver class object */
@@ -3138,6 +3137,7 @@ void cdcacm_uninitialize(FAR void *handle)
* free the memory resources. * free the memory resources.
*/ */
wd_delete(priv->rxfailsafe);
kmm_free(priv); kmm_free(priv);
return; return;
} }
@@ -3167,8 +3167,9 @@ void cdcacm_uninitialize(FAR void *handle)
#ifndef CONFIG_CDCACM_COMPOSITE #ifndef CONFIG_CDCACM_COMPOSITE
usbdev_unregister(&drvr->drvr); usbdev_unregister(&drvr->drvr);
/* And free the driver structure */ /* And free the memory resources. */
wd_delete(priv->rxfailsafe);
kmm_free(priv); kmm_free(priv);
#else #else
+1 -1
View File
@@ -1356,7 +1356,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate all endpoints... the endpoints will not be functional /* Pre-allocate all endpoints... the endpoints will not be functional
* until the SET CONFIGURATION request is processed in usbclass_setconfig. * until the SET CONFIGURATION request is processed in usbclass_setconfig.
* This is done here because there may be calls to kmm_malloc and the SET * This is done here because there may be calls to kmm_malloc and the SET
* CONFIGURATION processing probably occurrs within interrupt handling * CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail. * logic where kmm_malloc calls will fail.
*/ */
+1 -1
View File
@@ -2044,7 +2044,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate all endpoints... the endpoints will not be functional /* Pre-allocate all endpoints... the endpoints will not be functional
* until the SET CONFIGURATION request is processed in usbclass_setconfig. * until the SET CONFIGURATION request is processed in usbclass_setconfig.
* This is done here because there may be calls to kmm_malloc and the SET * This is done here because there may be calls to kmm_malloc and the SET
* CONFIGURATION processing probably occurrs within interrupt handling * CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail. * logic where kmm_malloc calls will fail.
*/ */
+1 -1
View File
@@ -302,7 +302,7 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate all endpoints... the endpoints will not be functional /* Pre-allocate all endpoints... the endpoints will not be functional
* until the SET CONFIGURATION request is processed in usbmsc_setconfig. * until the SET CONFIGURATION request is processed in usbmsc_setconfig.
* This is done here because there may be calls to kmm_malloc and the SET * This is done here because there may be calls to kmm_malloc and the SET
* CONFIGURATION processing probably occurrs within interrupt handling * CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail. * logic where kmm_malloc calls will fail.
*/ */
+1 -1
View File
@@ -381,7 +381,7 @@ int cdcacm_initialize(int minor, FAR void **handle);
* *
* Description: * Description:
* Un-initialize the USB storage class driver. This function is used * Un-initialize the USB storage class driver. This function is used
* internally by the USB composite driver to uninitialized the CDC/ACM * internally by the USB composite driver to uninitialize the CDC/ACM
* driver. This same interface is available (with an untyped input * driver. This same interface is available (with an untyped input
* parameter) when the CDC/ACM driver is used standalone. * parameter) when the CDC/ACM driver is used standalone.
* *