From: Ursula Braun <ursula.braun@de.ibm.com>
To: jgarzik@pobox.com, netdev@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Daniel <danielm77@spray.se>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Ursula Braun <ursula.braun@de.ibm.com>
Subject: [patch 1/4] claw: fix memory leak in claw_probe.
Date: Thu, 21 Aug 2008 17:10:22 +0200 [thread overview]
Message-ID: <20080821151652.052680000@linux.vnet.ibm.com> (raw)
In-Reply-To: 20080821151021.069615000@linux.vnet.ibm.com
[-- Attachment #1: 606-claw-memleak.diff --]
[-- Type: text/plain, Size: 2113 bytes --]
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
probe_error() frees memory only, if cgdev->dev.driver_data refers
to the claw_privbk structure. Move forward its setting in claw_probe()
to ensure proper freeing of claw_privbk allocations.
Cc: Daniel <danielm77@spray.se>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
---
drivers/s390/net/claw.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
Index: linux-2.6-uschi/drivers/s390/net/claw.c
===================================================================
--- linux-2.6-uschi.orig/drivers/s390/net/claw.c
+++ linux-2.6-uschi/drivers/s390/net/claw.c
@@ -271,6 +271,7 @@ claw_probe(struct ccwgroup_device *cgdev
if (!get_device(&cgdev->dev))
return -ENODEV;
privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
+ cgdev->dev.driver_data = privptr;
if (privptr == NULL) {
probe_error(cgdev);
put_device(&cgdev->dev);
@@ -305,7 +306,6 @@ claw_probe(struct ccwgroup_device *cgdev
privptr->p_env->p_priv = privptr;
cgdev->cdev[0]->handler = claw_irq_handler;
cgdev->cdev[1]->handler = claw_irq_handler;
- cgdev->dev.driver_data = privptr;
CLAW_DBF_TEXT(2, setup, "prbext 0");
return 0;
@@ -1960,19 +1960,16 @@ init_ccw_bk(struct net_device *dev)
static void
probe_error( struct ccwgroup_device *cgdev)
{
- struct claw_privbk *privptr;
+ struct claw_privbk *privptr;
CLAW_DBF_TEXT(4, trace, "proberr");
- privptr=(struct claw_privbk *)cgdev->dev.driver_data;
- if (privptr!=NULL) {
+ privptr = (struct claw_privbk *) cgdev->dev.driver_data;
+ if (privptr != NULL) {
+ cgdev->dev.driver_data = NULL;
kfree(privptr->p_env);
- privptr->p_env=NULL;
- kfree(privptr->p_mtc_envelope);
- privptr->p_mtc_envelope=NULL;
- kfree(privptr);
- privptr=NULL;
- }
- return;
+ kfree(privptr->p_mtc_envelope);
+ kfree(privptr);
+ }
} /* probe_error */
/*-------------------------------------------------------------------*
--
next prev parent reply other threads:[~2008-08-21 15:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-21 15:10 [patch 0/4] s390: ctcm / lcs / claw fixes for 2.6.27 Ursula Braun
2008-08-21 15:10 ` Ursula Braun [this message]
2008-08-21 15:10 ` [patch 2/4] claw: netdev->priv vs. netdev->ml_priv Ursula Braun
2008-08-21 15:10 ` [patch 3/4] ctcm: " Ursula Braun
2008-08-21 15:10 ` [patch 4/4] LCS recovery dumps when cable reconnect Ursula Braun
2008-08-27 9:19 ` Jeff Garzik
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=20080821151652.052680000@linux.vnet.ibm.com \
--to=ursula.braun@de.ibm.com \
--cc=danielm77@spray.se \
--cc=jgarzik@pobox.com \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
/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.