lkml.org 
[lkml]   [2001]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] memory leak in scsi_proc.c
Hi,

If someone writes to a scsi adapter's /proc entry and that scsi adapter
has not defined a proc_info() entry point, proc_scsi_write() will leak a
page. Furthermore, no sense asking for a page if said proc_info() entry
point does not exist. This patch fixes the above problem and patches
cleanly against 2.4.4

--- drivers/scsi/scsi_proc.c.orig Fri Feb 9 14:30:23 2001
+++ drivers/scsi/scsi_proc.c Thu May 24 22:26:59 2001
@@ -99,6 +99,9 @@
char * page;
char *start;

+ if (hpnt->hostt->proc_info == NULL)
+ return -ENOSYS;
+
if (count > PROC_BLOCK_SIZE)
return -EOVERFLOW;

@@ -106,12 +109,10 @@
return -ENOMEM;
copy_from_user(page, buf, count);

- if (hpnt->hostt->proc_info == NULL)
- ret = -ENOSYS;
- else
- ret = hpnt->hostt->proc_info(page, &start, 0, count,
- hpnt->host_no, 1);
+ ret = hpnt->hostt->proc_info(page, &start, 0, count,
+ hpnt->host_no, 1);
free_page((ulong) page);
+
return(ret);
}

-Michael F. Brown, UMass Lowell Computer Science

email: mbrown@cs.uml.edu

"In theory, there is no difference between theory and practice,
but in practice, there is." - Jan L.A. van de Snepscheut

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

\
 
 \ /
  Last update: 2005-03-22 12:53    [W:0.032 / U:1.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site