Commit 685e2ff2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix cciss memory leaks

From: Felipe W Damasio <felipewd@terra.com.br>

Fix a few error-path leaks in the cciss block driver.  Bug found by smatch
checker.
parent d2fa8630
...@@ -754,16 +754,24 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, ...@@ -754,16 +754,24 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
status = -ENOMEM; status = -ENOMEM;
goto cleanup1; goto cleanup1;
} }
if (copy_from_user(ioc, (void *) arg, sizeof(*ioc))) if (copy_from_user(ioc, (void *) arg, sizeof(*ioc))) {
return -EFAULT; status = -EFAULT;
goto cleanup1;
}
if ((ioc->buf_size < 1) && if ((ioc->buf_size < 1) &&
(ioc->Request.Type.Direction != XFER_NONE)) (ioc->Request.Type.Direction != XFER_NONE)) {
return -EINVAL; status = -EINVAL;
goto cleanup1;
}
/* Check kmalloc limits using all SGs */ /* Check kmalloc limits using all SGs */
if (ioc->malloc_size > MAX_KMALLOC_SIZE) if (ioc->malloc_size > MAX_KMALLOC_SIZE) {
return -EINVAL; status = -EINVAL;
if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) goto cleanup1;
return -EINVAL; }
if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) {
status = -EINVAL;
goto cleanup1;
}
buff = (unsigned char **) kmalloc(MAXSGENTRIES * buff = (unsigned char **) kmalloc(MAXSGENTRIES *
sizeof(char *), GFP_KERNEL); sizeof(char *), GFP_KERNEL);
if (!buff) { if (!buff) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment