mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@kernel.org>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, James Bottomley <James.Bottomley@suse.de>
Subject: Re: [PATCH] SCSI, target: Don't leak memory in error path in pscsi_alloc_task()
Date: Sat, 29 Jan 2011 14:56:27 -0800	[thread overview]
Message-ID: <1296341787.14831.237.camel@haakon2.linux-iscsi.org> (raw)
In-Reply-To: <alpine.LNX.2.00.1101292326510.19392@swampdragon.chaosbits.net>

On Sat, 2011-01-29 at 23:29 +0100, Jesper Juhl wrote:
> We'll leak the memory allocated via kzalloc() to 'pt' if the allocation of 
> memory for 'pt->pscsi_cdb' fails in pscsi_alloc_task().
> This patch fixes the leak by kfree()'ing the previously allocated memory 
> in the error path.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  target_core_pscsi.c |    1 +
>  1 file changed, 1 insertion(+)
> 
>   Compile tested only since I lack the hardware.
> 
> diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
> index 742d246..84561a0 100644
> --- a/drivers/target/target_core_pscsi.c
> +++ b/drivers/target/target_core_pscsi.c
> @@ -815,6 +815,7 @@ pscsi_alloc_task(struct se_cmd *cmd)
>  
>  		pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL);
>  		if (!(pt->pscsi_cdb)) {
> +			kfree(pt);
>  			printk(KERN_ERR "pSCSI: Unable to allocate extended"
>  					" pt->pscsi_cdb\n");
>  			return NULL;
> 
> 

Thanks, but this one was already fixed recently by Roland in
lio-core-2.6.git/linus-38-rc2, and included in the series to mainline as
[PATCH 04/24]:

commit 85133a962707b0e550c3f5f151557bed3e056869
Author: Roland Dreier <rolandd@cisco.com>
Date:   Sun Jan 16 06:59:51 2011 +0000

    target: Fix memory leak on error path

Best Regards,

--nab





      reply	other threads:[~2011-01-29 22:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-29 22:29 Jesper Juhl
2011-01-29 22:56 ` Nicholas A. Bellinger [this message]

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=1296341787.14831.237.camel@haakon2.linux-iscsi.org \
    --to=nab@kernel.org \
    --cc=James.Bottomley@suse.de \
    --cc=jj@chaosbits.net \
    --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®