On Fri, 2015-11-27 at 00:04 +0100, Steinar H. Gunderson wrote:
> On Thu, Nov 26, 2015 at 01:26:32AM +0100, Steinar H. Gunderson wrote:
> >> There are numerous smaller issues: The allocated memory needs to be
> >> charged against usbfs_memory_usage
> > I'll fix this.
>
> Fixed in updated patch (attached).
>
> > I'll fix this, too.
>
> Also fixed.
>
> Now also checkpatch clean.
>
> /* Steinar */
+static int usbdev_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ struct usb_memory *usbm = NULL;
+ struct usb_dev_state *ps = file->private_data;
+ size_t size = vma->vm_end - vma->vm_start;
+ int ret;
+
+ ret = usbfs_increase_memory_usage(size + sizeof(struct usb_memory));
+ if (ret)
+ return ret;
+
+ usbm = alloc_usb_memory(ps, size);
+ if (!usbm)
+ return -ENOMEM;
Looks like an accounting leak in the error case.
+
+ if (remap_pfn_range(vma, vma->vm_start,
+ virt_to_phys(usbm->mem) >> PAGE_SHIFT,
+ size, vma->vm_page_prot) < 0)
+ return -EAGAIN;
The same leak and a memory leak.
HTH
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html