2003-09-21 03:57:52

by Felipe W Damasio

[permalink] [raw]
Subject: [PATCH] Memory leak in block/cciss.c driver

--- linux-2.6.0-test5/drivers/block/cciss.c Mon Sep 8 16:50:32 2003
+++ linux-2.6.0-test5-fwd/drivers/block/cciss.c Sun Sep 21 00:46:33 2003
@@ -754,16 +754,24 @@
status = -ENOMEM;
goto cleanup1;
}
- if (copy_from_user(ioc, (void *) arg, sizeof(*ioc)))
- return -EFAULT;
+ if (copy_from_user(ioc, (void *) arg, sizeof(*ioc))) {
+ status = -EFAULT;
+ goto cleanup1;
+ }
if ((ioc->buf_size < 1) &&
- (ioc->Request.Type.Direction != XFER_NONE))
- return -EINVAL;
+ (ioc->Request.Type.Direction != XFER_NONE)) {
+ status = -EINVAL;
+ goto cleanup1;
+ }
/* Check kmalloc limits using all SGs */
- if (ioc->malloc_size > MAX_KMALLOC_SIZE)
- return -EINVAL;
- if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES)
- return -EINVAL;
+ if (ioc->malloc_size > MAX_KMALLOC_SIZE) {
+ status = -EINVAL;
+ goto cleanup1;
+ }
+ if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) {
+ status = -EINVAL;
+ goto cleanup1;
+ }
buff = (unsigned char **) kmalloc(MAXSGENTRIES *
sizeof(char *), GFP_KERNEL);
if (!buff) {


Attachments:
cciss-leak.patch (1.05 kB)