Skip to contentSkip to conversation

mptctl.c memory leak on failure

PATCH In review Arnaldo Carvalho de Melo 2 participants 3 messages Jan 7, 2001 LSI Logic MPT fusion drivers (FC/SAS/SPI)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mptctl.c memory leak on failure

Hi,

Please consider applying this patch. And I got confused by the
kmalloc and the comment: the buffer is used for DMA but the kmalloc doesn't has GFP_DMA, maybe I'm missing something here, its about time for me to sleep 8) but if it doesn't needs DMA you should consider using vmalloc and you'll get rid of the 32 pages limitation, like I did for wanrouter that used kmalloc but didn't needed DMA, so I've changed it to vmalloc as per Alan's cluebating^Wsuggestion at the time 8)

- Arnaldo

drivers/message/fusion/mptctl.c +10 -3
@@ -290,6 +290,7 @@
 	dma_addr_t		 fwbuf_dma;
 	FWDownloadTCSGE_t	*fwVoodoo;
 	SGEAllUnion_t		*fwSgl;
+	int ret;
 
 	dprintk((KERN_INFO "mptctl_do_fwdl called. mptctl_id = %xh.\n", mptctl_id)); //tc
 
@@ -309,20 +310,22 @@
 	}
 //dprintk((KERN_INFO "DbG: fwbuf       = %p\n", fwbuf));
 
+	ret = -EFAULT;
 	if (copy_from_user(fwbuf, ufwbuf, fwlen) < 0) {
 		printk(KERN_ERR "%s@%d::_ioctl_fwdl - "
 				"Unable to copy f/w buffer @ %p\n",
 				__FILE__, __LINE__, (void*)ufwbuf);
-		return -EFAULT;
+		goto out;
 	}
 
 	/* Perform Firmware download.
 	 */
 
+	ret = -ENXIO; /* (-6) No such device or address */
 	if ((ioc = mpt_verify_adapter(ioc, &iocp)) < 0) {
 		printk("%s@%d::_ioctl_fwdl - ioc%d not found!\n",
 				__FILE__, __LINE__, ioc);
-		return -ENXIO;			  /* (-6) No such device or address */
+		goto out;
 	}
 
 	mf = MptGetMsgFrame(mptctl_id, ioc);
@@ -373,8 +376,9 @@
 					   "In ReplyMsg loop - iteration %d\n",
 					   foo)); //tc
 			}
+			ret = -ETIME;
 			if (++foo > 60000000)
-				return -ETIME;
+				goto out;
 			mb();
 			schedule();
 			barrier();
@@ -402,6 +406,9 @@
 		printk(KERN_WARNING MYNAM ": (bad VooDoo):\n");
 		return -ENOMSG;
 	}
+	return 0;
+out:	kfree(fwbuf);
+	return ret;
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 2 lines

kmalloc and the comment: the buffer is used for DMA but the kmalloc doesn't has GFP_DMA, maybe I'm missing something here, its about time for me to

It should be kmalloc (or 2.4 wise pci_alloc_* I guess eventually). Its driven by 32bit busmaster DMA. Its non ISA so it doesnt need GFP_DMA
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Arnaldo Carvalho de Melo

Em Sun, Jan 07, 2001 at 01:37:15PM +0000, Alan Cox escreveu:

Quoted 5 lines
Quoted 2 lines

kmalloc and the comment: the buffer is used for DMA but the kmalloc doesn't has GFP_DMA, maybe I'm missing something here, its about time for me to

It should be kmalloc (or 2.4 wise pci_alloc_* I guess eventually). Its driven by 32bit busmaster DMA. Its non ISA so it doesnt need GFP_DMA

yap, I should have have some sleep before suggesting that 8) Now back looking at the other files, I've found another not so grave potential memory leak, patch in some minutes

- Arnaldo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/