From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161736AbcBSGlx (ORCPT ); Fri, 19 Feb 2016 01:41:53 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:47428 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161414AbcBSGlv (ORCPT ); Fri, 19 Feb 2016 01:41:51 -0500 Date: Thu, 18 Feb 2016 22:41:32 -0800 From: Calvin Owens To: , CC: , Subject: [PATCH][QUESTION] Intentional memory leak in ipmi_msghandler? Message-ID: <20160219064132.GA2859126@devbig337.prn1.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-02-19_05:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Thanks, Calvin ----8<---- From: Calvin Owens Subject: [PATCH] ipmi_msghandler: Don't leak memory on errors Signed-off-by: Calvin Owens --- 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) -- 2.4.6