[Stgt-devel] [Patch 1/6] Fix potential memory leak

Mark Harvey markh794
Wed Jun 20 13:00:25 CEST 2007


FUJITA Tomonori wrote:
> From: Mark Harvey <markh794 at gmail.com>
> Subject: [Stgt-devel] [Patch 1/6] Fix potential memory leak
> Date: Wed, 20 Jun 2007 17:57:44 +1000
>
>   
>> >From f25303a09128973d77df0bb49926001212548f1d Mon Sep 17 00:00:00 2001
>> From: Mark Harvey <markh794 at gmail.com>
>> Date: Wed, 20 Jun 2007 17:31:32 +1000
>> Subject: Fix memory leak in ibmvio -> spc_inquiry() path
>>
>> Allocating data = valloc() twice when calling spc_inquiry()
>>     
>
> Thanks for finding this bug.
>
> __ibmvio_inquiry should handle errors properly so I'll fix this in a
> different way.
>
>   

No problems... I found it while looking thru the code updating the 
ASC/ASCQ stuff.

BTW: Can the ibmvio be complied on an x86 linux host ?

Or am I doing something wrong.

>> Signed-off-by: Mark Harvey <markh794 at gmail.com>
>> ---
>>  usr/ibmvio/ibmvio.c |   15 +++++++--------
>>  1 files changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/usr/ibmvio/ibmvio.c b/usr/ibmvio/ibmvio.c
>> index 5a2f8fe..1b1785d 100644
>> --- a/usr/ibmvio/ibmvio.c
>> +++ b/usr/ibmvio/ibmvio.c
>> @@ -145,17 +145,16 @@ static int ibmvio_inquiry(int host_no, struct scsi_cmd *cmd)
>>  	if (((scb[1] & 0x3) == 0x3) || (!(scb[1] & 0x3) && scb[2]))
>>  		goto sense;
>>  
>> -	data = valloc(pagesize);
>> -	if (!data) {
>> -		key = HARDWARE_ERROR;
>> -		asc = 0;
>> -		goto sense;
>> -	}
>> -	memset(data, 0, pagesize);
>> -
>>  	dprintf("%x %x\n", scb[1], scb[2]);
>>  
>>  	if (!(scb[1] & 0x3)) {
>> +		data = valloc(pagesize);
>> +		if (!data) {
>> +			key = HARDWARE_ERROR;
>> +			asc = 0;
>> +			goto sense;
>> +		}
>> +		memset(data, 0, pagesize);
>>  		cmd->len = __ibmvio_inquiry(host_no, cmd, data);
>>  		ret = SAM_STAT_GOOD;
>>  	} else
>> -- 
>> 1.5.2.1
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Stgt-devel mailing list
>> Stgt-devel at lists.berlios.de
>> https://lists.berlios.de/mailman/listinfo/stgt-devel
>>
>>     
>
>   




More information about the stgt mailing list