From: Jesper Juhl <jesper.juhl@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Andrea Bittau <a.bittau@cs.ucl.ac.uk>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
dccp@vger.kernel.org, Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH][dccp] Fix memory leak and clean up style - dccp_feat_empty_confirm()
Date: Fri, 27 Jul 2007 00:39:37 +0200 [thread overview]
Message-ID: <200707270039.37860.jesper.juhl@gmail.com> (raw)
Greetings,
There's a memory leak in net/dccp/feat.c::dccp_feat_empty_confirm().
If we hit the 'default:' case of the 'switch' statement, then we
return without freeing 'opt', thus leaking 'struct dccp_opt_pend'
bytes.
The leak is fixed easily enough by adding a kfree(opt); before the
return statement.
The patch also changes the layout of the 'switch' to be more in line
with CodingStyle.
Patch has been compile tested.
Please consider merging.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
net/dccp/feat.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index cd845df..5ebdd86 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -327,10 +327,16 @@ static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk,
}
switch (type) {
- case DCCPO_CHANGE_L: opt->dccpop_type = DCCPO_CONFIRM_R; break;
- case DCCPO_CHANGE_R: opt->dccpop_type = DCCPO_CONFIRM_L; break;
- default: DCCP_WARN("invalid type %d\n", type); return;
-
+ case DCCPO_CHANGE_L:
+ opt->dccpop_type = DCCPO_CONFIRM_R;
+ break;
+ case DCCPO_CHANGE_R:
+ opt->dccpop_type = DCCPO_CONFIRM_L;
+ break;
+ default:
+ DCCP_WARN("invalid type %d\n", type);
+ kfree(opt);
+ return;
}
opt->dccpop_feat = feature;
opt->dccpop_val = NULL;
PS. Please keep me on Cc when replying.
next reply other threads:[~2007-07-26 22:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-26 22:39 Jesper Juhl [this message]
2007-07-26 23:16 ` Ian McDonald
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=200707270039.37860.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=a.bittau@cs.ucl.ac.uk \
--cc=acme@ghostprotocols.net \
--cc=dccp@vger.kernel.org \
--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®