Skip to contentSkip to conversation

Memory leak in block/cciss.c driver

PATCH New Felipe W Damasio 1 participant 1 message Sep 21, 2003 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Memory leak in block/cciss.c driver

Hi Linus,

Patch against 2.6-test5 which removes a few memory leaks from the cciss
block driver.

Bug found by smatch checker.

Please apply,

Cheers.

Felipe

Signature · 2 lines
It's most certainly GNU/Linux, not Linux. Read more at
http://www.gnu.org/gnu/why-gnu-linux.html
drivers/block/cciss.c +16 -8
@@ -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) {