linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: Calvin Owens <calvinowens@fb.com>,
	openipmi-developer@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH][QUESTION] Intentional memory leak in ipmi_msghandler?
Date: Fri, 19 Feb 2016 07:14:55 -0600	[thread overview]
Message-ID: <56C7154F.3040604@acm.org> (raw)
In-Reply-To: <20160219064132.GA2859126@devbig337.prn1.facebook.com>

On 02/19/2016 12:41 AM, Calvin Owens wrote:
> Hello,
>
> I've got a few boxes that are leaking memory in handle_new_recv_msgs()
> in ipmi_msghandler. AFAICS this is intentional, there's even an explicit
> counter that tracks the number of times smi_msg is leaked.

Are you 100% sure about this?  There's no intentional leak, a negative 
return
from this function means the message was used for another purpose and
thus shouldn't be freed.  There's only one situation where this happens and
you should never hit it in normal operation.

> I'm guessing there was a reason for doing this, but there wasn't any
> discussion about it on LKML when the patch was accepted. Can you clarify
> why something like the below patch won't work? I tried it on one of my
> leaky boxes and nothing obviously horrible happened.

Well, that's because nothing probably happened, and it probably had no
effect on the leak.  A better comment on this code is probably in order.
But that patch is incorrect.

I doubt the leak is here.  If you are having a leak, is it possible to 
characterize
it better?  Are you handling commands from IPMB?  Are you handling LAN
commands here?

-corey

>
> Thanks,
> Calvin
>
> ----8<----
> From: Calvin Owens <calvinowens@fb.com>
> Subject: [PATCH] ipmi_msghandler: Don't leak memory on errors
>
> Signed-off-by: Calvin Owens <calvinowens@fb.com>
> ---
>   drivers/char/ipmi/ipmi_msghandler.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 94fb407..ed82ffa 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -3834,10 +3834,7 @@ static void handle_new_recv_msgs(ipmi_smi_t intf)
>   			break;
>   		} else {
>   			list_del(&smi_msg->link);
> -			if (rv == 0)
> -				/* Message handled */
> -				ipmi_free_smi_msg(smi_msg);
> -			/* If rv < 0, fatal error, del but don't free. */
> +			ipmi_free_smi_msg(smi_msg);
>   		}
>   	}
>   	if (!run_to_completion)

  reply	other threads:[~2016-02-19 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19  6:41 [PATCH][QUESTION] Intentional memory leak in ipmi_msghandler? Calvin Owens
2016-02-19 13:14 ` Corey Minyard [this message]
2016-02-22 19:19   ` Calvin Owens

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=56C7154F.3040604@acm.org \
    --to=minyard@acm.org \
    --cc=calvinowens@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).