[PATCH] drivers/char/istallion.c: fix leakage on failure

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Mon Aug 14 2000 - 11:29:52 EST


Hi,

   Please take a look and consider applying. This driver would benefit
of using spinlocks instead of cli/sti, if I had a board and the maintainer
allowed I could do it.

                        - Arnaldo

--- linux-2.4.0-test7-pre3/drivers/char/istallion.c Fri Jul 28 06:34:41 2000
+++ linux-2.4.0-test7-pre3.acme/drivers/char/istallion.c Mon Aug 14 13:24:22 2000
@@ -22,6 +22,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Changes:
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/14/2000
+ * - fix leakage on failure in stli_findeisabrds and stli_initpcibrd
  */
 
 /*****************************************************************************/
@@ -4596,8 +4600,10 @@
  */
                 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL)
                         return(-ENOMEM);
- if ((brdp->brdnr = stli_getbrdnr()) < 0)
- return(-ENOMEM);
+ if ((brdp->brdnr = stli_getbrdnr()) < 0) {
+ kfree(brdp);
+ return -ENOMEM;
+ }
                 eid = inb(iobase + 0xc82);
                 if (eid == ECP_EISAID)
                         brdp->brdtype = BRD_ECPE;
@@ -4613,6 +4619,7 @@
         }
 
         return(0);
+
 }
 
 /*****************************************************************************/
@@ -4661,6 +4668,7 @@
         if ((brdp->brdnr = stli_getbrdnr()) < 0) {
                 printk("STALLION: too many boards found, "
                         "maximum supported %d\n", STL_MAXBRDS);
+ kfree(brdp);
                 return(0);
         }
         brdp->brdtype = brdtype;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:36 EST