From: Joe Perches <joe@perches.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
Andy Grover <agrover@redhat.com>,
Roland Dreier <roland@kernel.org>, Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix leak in drivers/target/iscsi/iscsi_target_parameters.c::iscsi_copy_param_list()
Date: Sun, 31 Jul 2011 15:44:34 -0700 [thread overview]
Message-ID: <1312152274.11635.8.camel@Joe-Laptop> (raw)
In-Reply-To: <alpine.LNX.2.00.1108010017030.28695@swampdragon.chaosbits.net>
On Mon, 2011-08-01 at 00:28 +0200, Jesper Juhl wrote:
> We leak memory if the allocations for 'new_param->name' or 'new_param->value' fail.
> We also do a lot of variable assignments that are completely pointless
> if the allocations fail.
> So, let's move the allocations before the assignments and also make
> sure that we free whatever was allocated to one if the allocation for
> another fails.
> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
[]
> + new_param->name = kmalloc(strlen(param->name) + 1, GFP_KERNEL);
> + new_param->value = kmalloc(strlen(param->value) + 1, GFP_KERNEL);
[]
> memcpy(new_param->name, param->name, strlen(param->name));
> new_param->name[strlen(param->name)] = '\0';
> memcpy(new_param->value, param->value, strlen(param->value));
kstrdup
next prev parent reply other threads:[~2011-07-31 22:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-31 22:28 Jesper Juhl
2011-07-31 22:33 ` Jesper Juhl
2011-07-31 22:44 ` Joe Perches [this message]
2011-08-01 20:32 ` [PATCH v2] " Jesper Juhl
2011-08-01 23:32 ` Joe Perches
2011-08-02 8:26 ` [PATCH v3] " Jesper Juhl
2011-08-04 18:04 ` Nicholas A. Bellinger
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=1312152274.11635.8.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=agrover@redhat.com \
--cc=hch@lst.de \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=roland@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®