re: usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Ashwini Pahuja,

The patch efed421a94e6: "usb: gadget: Add UDC driver for Broadcom
USB3.0 device controller IP BDC" from Nov 13, 2014, leads to the
following static checker warning:

	drivers/usb/gadget/udc/bdc/bdc_ep.c:193 ep_bd_list_alloc()
	warn: possible memory leak of 'bd_table'

drivers/usb/gadget/udc/bdc/bdc_ep.c
   153          for (index = 0; index < num_tabs; index++) {
   154                  /* Allocate memory for bd_table structure */
   155                  bd_table = kzalloc(sizeof(struct bd_table), GFP_ATOMIC);
   156                  if (!bd_table)
   157                          goto fail;
   158  
   159                  bd_table->start_bd = dma_pool_alloc(bdc->bd_table_pool,
   160                                                          GFP_ATOMIC,
   161                                                          &dma);
   162                  if (!bd_table->start_bd)

Assume that the dma_pool_alloc() alloc fails.

   163                          goto fail;
   164  
   165                  bd_table->dma = dma;
   166  
   167                  dev_dbg(bdc->dev,
   168                          "index:%d start_bd:%p dma=%08llx prev_table:%p\n",
   169                          index, bd_table->start_bd,
   170                          (unsigned long long)bd_table->dma, prev_table);
   171  
   172                  ep->bd_list.bd_table_array[index] = bd_table;
   173                  memset(bd_table->start_bd, 0, bd_p_tab * sizeof(struct bdc_bd));
   174                  if (prev_table)
   175                          chain_table(prev_table, bd_table, bd_p_tab);
   176  
   177                  prev_table = bd_table;
   178          }
   179          chain_table(prev_table, ep->bd_list.bd_table_array[0], bd_p_tab);
   180          /* Memory allocation is successful, now init the internal fields */
   181          ep->bd_list.num_tabs = num_tabs;
   182          ep->bd_list.max_bdi  = (num_tabs * bd_p_tab) - 1;
   183          ep->bd_list.num_tabs = num_tabs;
   184          ep->bd_list.num_bds_table = bd_p_tab;
   185          ep->bd_list.eqp_bdi = 0;
   186          ep->bd_list.hwd_bdi = 0;
   187  
   188          return 0;
   189  fail:
   190          /* Free the bd_table_array, bd_table struct, bd's */
   191          ep_bd_list_free(ep, num_tabs);

We end up leaking memory here.

   192  
   193          return -ENOMEM;
   194  }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux