All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@free-electrons.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: net: add a hardware buffer management helper API
Date: Fri, 18 Mar 2016 16:34:14 +0000	[thread overview]
Message-ID: <87io0joid5.fsf@free-electrons.com> (raw)
In-Reply-To: <20160316195012.GB20386@mwanda>

Hi Dan,
 
 On mer., mars 16 2016, Dan Carpenter <dan.carpenter@oracle.com> wrote:

> 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.

I will prepare a patch to fix it.

Thanks,

Gregory

>
>     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

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

      reply	other threads:[~2016-03-18 16:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 19:50 net: add a hardware buffer management helper API Dan Carpenter
2016-03-18 16:34 ` Gregory CLEMENT [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87io0joid5.fsf@free-electrons.com \
    --to=gregory.clement@free-electrons.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.