usbdev: a memory leak occurred when the usb uninitialize process was executed
In usbclass_unbind, DEV_FREEEP is called first, and later usbclass_freereq does not free memory due to ep NULL Signed-off-by: sunkun3 <sunkun3@xiaomi.com>
This commit is contained in:
parent
7dde402982
commit
052d46c690
@ -1053,22 +1053,6 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
usbclass_resetconfig(priv);
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkin);
|
||||
priv->epbulkin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
||||
if (priv->epbulkout)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkout);
|
||||
priv->epbulkout = NULL;
|
||||
}
|
||||
|
||||
/* Free write requests that are not in use (which should be all
|
||||
* of them
|
||||
*/
|
||||
@ -1094,6 +1078,22 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
usbdev_freereq(priv->epbulkin, wrcontainer->req);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkin);
|
||||
priv->epbulkin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
||||
if (priv->epbulkout)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkout);
|
||||
priv->epbulkout = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1463,14 +1463,6 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
cdcacm_resetconfig(priv);
|
||||
up_mdelay(50);
|
||||
|
||||
/* Free the interrupt IN endpoint */
|
||||
|
||||
if (priv->epintin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epintin);
|
||||
priv->epintin = NULL;
|
||||
}
|
||||
|
||||
/* Free the pre-allocated control request */
|
||||
|
||||
if (priv->ctrlreq != NULL)
|
||||
@ -1494,14 +1486,6 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
||||
if (priv->epbulkout)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkout);
|
||||
priv->epbulkout = NULL;
|
||||
}
|
||||
|
||||
/* Free write requests that are not in use (which should be all
|
||||
* of them)
|
||||
*/
|
||||
@ -1522,6 +1506,22 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
DEBUGASSERT(priv->nwrq == 0);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Free the interrupt IN endpoint */
|
||||
|
||||
if (priv->epintin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epintin);
|
||||
priv->epintin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
||||
if (priv->epbulkout)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkout);
|
||||
priv->epbulkout = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
|
@ -1479,22 +1479,6 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
usbclass_resetconfig(priv);
|
||||
up_mdelay(50);
|
||||
|
||||
/* Free the interrupt IN endpoint */
|
||||
|
||||
if (priv->epintin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epintin);
|
||||
priv->epintin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkin);
|
||||
priv->epbulkin = NULL;
|
||||
}
|
||||
|
||||
/* Free the pre-allocated control request */
|
||||
|
||||
if (priv->ctrlreq != NULL)
|
||||
@ -1544,6 +1528,22 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
DEBUGASSERT(priv->nwrq == 0);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Free the interrupt IN endpoint */
|
||||
|
||||
if (priv->epintin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epintin);
|
||||
priv->epintin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkin);
|
||||
priv->epbulkin = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear out all data in the circular buffer */
|
||||
|
@ -2289,22 +2289,6 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
usbclass_resetconfig(priv);
|
||||
up_mdelay(50);
|
||||
|
||||
/* Free the interrupt IN endpoint */
|
||||
|
||||
if (priv->epintin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epintin);
|
||||
priv->epintin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkin);
|
||||
priv->epbulkin = NULL;
|
||||
}
|
||||
|
||||
/* Free the pre-allocated control request */
|
||||
|
||||
if (priv->ctrlreq != NULL)
|
||||
@ -2328,14 +2312,6 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
usbdev_freereq(priv->epbulkout, priv->rdreq);
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
||||
if (priv->epbulkout)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkout);
|
||||
priv->epbulkout = NULL;
|
||||
}
|
||||
|
||||
netdev_unregister(&priv->netdev);
|
||||
|
||||
/* Free write requests that are not in use (which should be all
|
||||
@ -2354,6 +2330,30 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Free the interrupt IN endpoint */
|
||||
|
||||
if (priv->epintin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epintin);
|
||||
priv->epintin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk IN endpoint */
|
||||
|
||||
if (priv->epbulkin)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkin);
|
||||
priv->epbulkin = NULL;
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
||||
if (priv->epbulkout)
|
||||
{
|
||||
DEV_FREEEP(dev, priv->epbulkout);
|
||||
priv->epbulkout = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user