From: Jesper Juhl <jesper.juhl@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Greg Kroah-Hartman <greg@kroah.com>,
gregkh@us.ibm.com, jesper.juhl@gmail.com
Subject: [PATCH] Fix small mem leak in IBM Hot Plug Controller Driver
Date: Sat, 8 Mar 2008 02:16:07 +0100 (CET) [thread overview]
Message-ID: <alpine.LNX.1.00.0803080204170.1856@dragon.funnycrock.com> (raw)
In drivers/pci/hotplug/ibmphp_ebda.c::ebda_rsrc_controller(), storage is
allocated with kzalloc() and assigned to 'tmp_slot'.
Then lots of stuff, like ->flag, ->supported_speed etc is set in tmp_slot.
A bit further down there's then this test :
if (!bus_info_ptr1) {
rc = -ENODEV;
goto error;
}
At this point, tmp_slot has not been assigned to anything, so when
erroring-out we want to free it, but nothing at the 'error:' label free's
'tmp_slot' - and we can't really free 'tmp_slot' at 'error:' since we may
jump to that label later when 'tmp_slot' *has* been used and we do not
want it freed. So, the only sane option left seems to be to
kfree(tmp_slot) just before jumping to the 'error:' label in the one place
where this is what actually makes sense. The following patch does just
that and thus kills off a tiny potential memory leak.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
ibmphp_ebda.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 600ed7b..bbccde9 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -963,6 +963,7 @@ static int __init ebda_rsrc_controller (void)
bus_info_ptr1 = ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num);
if (!bus_info_ptr1) {
+ kfree(tmp_slot);
rc = -ENODEV;
goto error;
}
reply other threads:[~2008-03-08 1:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=alpine.LNX.1.00.0803080204170.1856@dragon.funnycrock.com \
--to=jesper.juhl@gmail.com \
--cc=greg@kroah.com \
--cc=gregkh@us.ibm.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®