[PATCH] memory leak in scsi_proc.c

Mike Brown (mbrown@cs.uml.edu)
Thu, 24 May 2001 22:49:23 -0400 (EDT)


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/