[PATCH] scsi: dpt_i2o: fix memory leak

Previous thread: Re: Workaround hardware bug addressing physical address by Unai Uribarri on Wednesday, July 14, 2010 - 10:07 am. (1 message)

Next thread: [PATCH 01/11] arch/h8300/kernel/traps.c: formatting of pointers in printk() by Kulikov Vasiliy on Wednesday, July 14, 2010 - 11:00 am. (1 message)
From: Kulikov Vasiliy
Date: Wednesday, July 14, 2010 - 10:53 am

Free allocated memory if adpt_ioctl_to_context() failed.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 drivers/scsi/dpt_i2o.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index f2d4df1..dd9a43b 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1839,8 +1839,10 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg)
 	sg_offset = (msg[0]>>4)&0xf;
 	msg[2] = 0x40000000; // IOCTL context
 	msg[3] = adpt_ioctl_to_context(pHba, reply);
-	if (msg[3] == (u32)-1)
+	if (msg[3] == (u32)-1) {
+		kfree(reply);
 		return -EBUSY;
+	}
 
 	memset(sg_list,0, sizeof(sg_list[0])*pHba->sg_tablesize);
 	if(sg_offset) {
-- 
1.7.0.4

--

From: Kulikov Vasiliy
Date: Wednesday, July 14, 2010 - 12:05 pm

Hmm right, but it is very strange coding style - function frees resources
that it did not allocated on error and does not free them on success.

Please, ignore this patch. Sorry for the noise.
--

Previous thread: Re: Workaround hardware bug addressing physical address by Unai Uribarri on Wednesday, July 14, 2010 - 10:07 am. (1 message)

Next thread: [PATCH 01/11] arch/h8300/kernel/traps.c: formatting of pointers in printk() by Kulikov Vasiliy on Wednesday, July 14, 2010 - 11:00 am. (1 message)