linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: Steve.Ralston@lsil.com
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: [PATCH] mptctl.c memory leak on failure
Date: Sun, 7 Jan 2001 01:12:26 -0200	[thread overview]
Message-ID: <20010107011226.C8362@conectiva.com.br> (raw)

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

--- linux-2.4.0-ac3/drivers/message/fusion/mptctl.c	Sat Jan  6 23:13:11 2001
+++ linux-2.4.0-ac3.acme/drivers/message/fusion/mptctl.c	Sun Jan  7 01:02:52 2001
@@ -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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

             reply	other threads:[~2001-01-07  3:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-07  3:12 Arnaldo Carvalho de Melo [this message]
2001-01-07 13:37 ` [PATCH] mptctl.c memory leak on failure Alan Cox
2001-01-07 16:09   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010107011226.C8362@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=Steve.Ralston@lsil.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).