nuttx/drivers/usbhost
Gregory Nutt d09f6aaa72 Correct more improper use of malloc(), zalloc(), and free()
malloc() and free() should never be used within the OS. This will work in the FLAT build because there is only a single heap, but will cause problems in PROTECTED and KERNEL build modes where there are separate heaps for user and kernel memory.

Typically kmm_malloc(), kmm_zalloc(), and kmm_free() should be called within the kernel in those build modes to use the kernel heap.

Memory is never free.  Possible memory leak:

    ./boards/arm/cxd56xx/common/src/cxd56_crashdump.c:  pdump = malloc(sizeof(fullcontext_t));

Memory allocated with malloc(), but freed with kmm_free():

    ./drivers/usbhost/usbhost_composite.c:  cfgbuffer = (FAR uint8_t *)malloc(CUSTOM_CONFIG_BUFSIZE);

Memory is never freed in these cases.  It is allocated in the driver initialization logic, but there is no corresponding uninitialization logic; memory is not freed on error conditions:

    ./arch/arm/src/lc823450/lc823450_i2s.c:  priv = (struct lc823450_i2s_s *)zalloc(sizeof(struct lc823450_i2s_s));
    ./arch/arm/src/sam34/sam_spi.c:  spics = (struct sam_spics_s *)zalloc(sizeof(struct sam_spics_s));
    ./arch/arm/src/sama5/sam_spi.c:  spics = (struct sam_spics_s *)zalloc(sizeof(struct sam_spics_s));
    ./arch/arm/src/samv7/sam_spi.c:  spics = (struct sam_spics_s *)zalloc(sizeof(struct sam_spics_s));

Memory is allocated with zalloc() but freed on error conditions with kmm_free():

    ./arch/arm/src/sama5/sam_ssc.c:  priv = (struct sam_ssc_s *)zalloc(sizeof(struct sam_ssc_s));
    ./arch/arm/src/samv7/sam_ssc.c:  priv = (struct sam_ssc_s *)zalloc(sizeof(struct sam_ssc_s));
    ./arch/arm/src/stm32/stm32_i2s.c:  priv = (struct stm32_i2s_s *)zalloc(sizeof(struct stm32_i2s_s));

Memory is never freed:

    ./drivers/spi/spi_bitbang.c:  priv = (FAR struct spi_bitbang_s *)zalloc(sizeof(struct spi_bitbang_s));
2020-08-04 20:41:43 +01:00
..
hid_parser.c drivers/usbhost/hid_parser.c: nxstyle fixes 2020-08-03 22:52:31 -05:00
Kconfig Fix issues reported on PR #1233 2020-06-15 07:13:21 -06:00
Make.defs Add support to CDC-MBIM USB host driver 2020-06-15 07:13:21 -06:00
usbhost_cdcacm.c
usbhost_cdcmbim.c Fix devif_timer() function call 2020-06-15 07:13:21 -06:00
usbhost_composite.c Correct more improper use of malloc(), zalloc(), and free() 2020-08-04 20:41:43 +01:00
usbhost_composite.h
usbhost_devaddr.c
usbhost_enumerate.c
usbhost_findclass.c
usbhost_ft232r.c
usbhost_hidkbd.c
usbhost_hidmouse.c
usbhost_hub.c
usbhost_max3421e.c
usbhost_registerclass.c
usbhost_registry.c
usbhost_registry.h
usbhost_skeleton.c
usbhost_storage.c
usbhost_trace.c
usbhost_xboxcontroller.c