• Jesper Juhl's avatar
    drivers/scsi/aacraid/commctrl.c: fix mem leak in aac_send_raw_srb() · 7dd72f51
    Jesper Juhl authored
    We leak in drivers/scsi/aacraid/commctrl.c::aac_send_raw_srb() :
    
    We allocate memory:
    
    	...
    	struct user_sgmap* usg;
    	usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
    	  + sizeof(struct sgmap), GFP_KERNEL);
    
    and then neglect to free it:
    
    	...
    	for (i = 0; i < usg->count; i++) {
    		u64 addr;
    		void* p;
    		if (usg->sg[i].count >
    		    ((dev->adapter_info.options &
    		     AAC_OPT_NEW_COMM) ?
    		      (dev->scsi_host_ptr->max_sectors << 9) :
    		      65536)) {
    			rcode = -EINVAL;
    			goto cleanup;
    	... this 'goto' makes 'usg' go out of scope and leak the memory we
    	    allocated.
    
    Other exits properly kfree(usg), it's just here it is neglected.
    Signed-off-by: default avatarJesper Juhl <jj@chaosbits.net>
    Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    7dd72f51
commctrl.c 23.4 KB