public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* re: net: add a hardware buffer management helper API
@ 2016-03-16 19:50 Dan Carpenter
  2016-03-18 16:34 ` Gregory CLEMENT
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-03-16 19:50 UTC (permalink / raw)
  To: kernel-janitors

Hello Gregory CLEMENT,

The patch 8cb2d8bf57e6: "net: add a hardware buffer management helper
API" from Mar 14, 2016, leads to the following static checker warning:

	net/core/hwbm.c:46 hwbm_pool_refill()
	warn: possible memory leak of 'buf'

net/core/hwbm.c
    26  /* Refill processing for HW buffer management */
    27  int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
    28  {
    29          int frag_size = bm_pool->frag_size;
    30          void *buf;
    31  
    32          if (likely(frag_size <= PAGE_SIZE))
    33                  buf = netdev_alloc_frag(frag_size);
    34          else
    35                  buf = kmalloc(frag_size, gfp);
    36  
    37          if (!buf)
    38                  return -ENOMEM;
    39  
    40          if (bm_pool->construct)

If we don't have a ->construct() then we leak memory.  This test should
probably be moved to the start of the function or deleted.

    41                  if (bm_pool->construct(bm_pool, buf)) {
    42                          hwbm_buf_free(bm_pool, buf);
    43                          return -ENOMEM;
    44                  }
    45  
    46          return 0;
    47  }
    48  EXPORT_SYMBOL_GPL(hwbm_pool_refill);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-18 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 19:50 net: add a hardware buffer management helper API Dan Carpenter
2016-03-18 16:34 ` Gregory CLEMENT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox