Hi David. Sorry, I did not think about that. This is a very good point and suggestion.
I will check and fix source code. Thank you for your advice. BR. Chris. -----Original Message----- From: David Binderman [mailto:dcb...@hotmail.com] Sent: Monday, July 27, 2015 7:01 PM To: Park, Chris; Kim, Johnny; Kim, Rachel; Lee, Dean; linux-wireless@vger.kernel.org Subject: RE: linux-4.2-rc4/drivers/staging/wilc1000/linux_mon.c:264: memory leak ? Hello there, ________________________________ > but It is not memory leak because If tx queue is complete, kfree() is > called in mgmt_tx_complete() funtion. Maybe I've been slightly less than clear. I'll have another go. There is a call to kmalloc around line 250. Source code is mgmt_tx = kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC); A few lines later is a second call to kmalloc mgmt_tx->buff = kmalloc(len, GFP_ATOMIC); If the second call fails, then proper tidyup would normally include calling kfree for the first call. This doesn't happen in the error handling code for the second call. if (mgmt_tx->buff == NULL) { PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); return WILC_FAIL; } Not a big bug, I admit, but might be worth fixing. Something like if (mgmt_tx->buff == NULL) { kfree(mgmt); PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); return WILC_FAIL; } would probably fix it. My apologies for not being clear earlier. Regards David Binderman > > Source code is > > g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, > mgmt_tx->size, mgmt_tx_complete); > > static void mgmt_tx_complete(void *priv, int status) > { > ... > kfree(pv_data->buff); > kfree(pv_data); > } > > BR. > Chris > > On 2015년 07월 27일 17:20, David Binderman wrote: > > Hello there, > > [linux-4.2-rc4/drivers/staging/wilc1000/linux_mon.c:264]: (error) > Memory leak: mgmt_tx > > Source code is > > mgmt_tx->buff = kmalloc(len, GFP_ATOMIC); > if (mgmt_tx->buff == NULL) { > PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); > return WILC_FAIL; > > } > > Suggest add missing call to kfree. > > > Regards > > David Binderman > > >