* [PATCH] SCSI, target: Don't leak memory in error path in pscsi_alloc_task()
@ 2011-01-29 22:29 Jesper Juhl
2011-01-29 22:56 ` Nicholas A. Bellinger
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-01-29 22:29 UTC (permalink / raw)
To: linux-kernel
Cc: Nicholas A. Bellinger, James Bottomley, Nicholas A. Bellinger
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;
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] SCSI, target: Don't leak memory in error path in pscsi_alloc_task()
2011-01-29 22:29 [PATCH] SCSI, target: Don't leak memory in error path in pscsi_alloc_task() Jesper Juhl
@ 2011-01-29 22:56 ` Nicholas A. Bellinger
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2011-01-29 22:56 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel, James Bottomley
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-29 22:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-29 22:29 [PATCH] SCSI, target: Don't leak memory in error path in pscsi_alloc_task() Jesper Juhl
2011-01-29 22:56 ` Nicholas A. Bellinger
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.