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

View file

@ -696,7 +696,7 @@ NOTES:
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
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
============

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
* successful buffered. In the case of RX buffer overrun,
* cdcacm_recvpacket() will return a failure (-ENOSPC) and will
* set the req->offset field
* set the req->offset field.
*/
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
* 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
* CONFIGURATION processing probably occurrs within interrupt handling
* CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail.
*/
@ -3003,6 +3003,7 @@ int cdcacm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
return OK;
errout_with_class:
wd_delete(priv->rxfailsafe);
kmm_free(alloc);
return ret;
}
@ -3055,11 +3056,9 @@ int cdcacm_initialize(int minor, FAR void **handle)
*/
devinfo.nendpoints = CDCACM_NUM_EPS;
#ifndef CONFIG_CDCACM_COMPOSITE
devinfo.epno[CDCACM_EP_INTIN_IDX] = CONFIG_CDCACM_EPINTIN;
devinfo.epno[CDCACM_EP_BULKIN_IDX] = CONFIG_CDCACM_EPBULKIN;
devinfo.epno[CDCACM_EP_BULKOUT_IDX] = CONFIG_CDCACM_EPBULKOUT;
#endif
/* Get an instance of the serial driver class object */
@ -3138,6 +3137,7 @@ void cdcacm_uninitialize(FAR void *handle)
* free the memory resources.
*/
wd_delete(priv->rxfailsafe);
kmm_free(priv);
return;
}
@ -3167,8 +3167,9 @@ void cdcacm_uninitialize(FAR void *handle)
#ifndef CONFIG_CDCACM_COMPOSITE
usbdev_unregister(&drvr->drvr);
/* And free the driver structure */
/* And free the memory resources. */
wd_delete(priv->rxfailsafe);
kmm_free(priv);
#else

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
* 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
* CONFIGURATION processing probably occurrs within interrupt handling
* CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail.
*/

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
* 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
* CONFIGURATION processing probably occurrs within interrupt handling
* CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail.
*/

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
* 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
* CONFIGURATION processing probably occurrs within interrupt handling
* CONFIGURATION processing probably occurs within interrupt handling
* logic where kmm_malloc calls will fail.
*/

View file

@ -381,7 +381,7 @@ int cdcacm_initialize(int minor, FAR void **handle);
*
* Description:
* 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
* parameter) when the CDC/ACM driver is used standalone.
*