[PATCH v3] usb: mon: Change return type to vm_fault_t
Use new return type vm_fault_t for the fault handler in struct vm_operations_struct. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type. Reference id -> 1c8f422059ae ("mm: change return type to vm_fault_t") Signed-off-by: Souptick Joarder <jrdr.li...@gmail.com> Reviewed-by: Matthew Wilcox <mawil...@microsoft.com> --- v2: Modified the change logs. v3: Modified change log drivers/usb/mon/mon_bin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 2761fad..34e866ad 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -1227,7 +1227,7 @@ static void mon_bin_vma_close(struct vm_area_struct *vma) /* * Map ring pages to user space. */ -static int mon_bin_vma_fault(struct vm_fault *vmf) +static vm_fault_t mon_bin_vma_fault(struct vm_fault *vmf) { struct mon_reader_bin *rp = vmf->vma->vm_private_data; unsigned long offset, chunk_idx; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: mon: Change return type to vm_fault_t
Use new return type vm_fault_t for the fault handler in struct vm_operations_struct. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type. Reference commit id-> 1c8f422059ae5da07db7406ab916203f9417e396 Signed-off-by: Souptick Joarder <jrdr.li...@gmail.com> Reviewed-by: Matthew Wilcox <mawil...@microsoft.com> --- v2: Modified the change logs. drivers/usb/mon/mon_bin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 2761fad..34e866ad 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -1227,7 +1227,7 @@ static void mon_bin_vma_close(struct vm_area_struct *vma) /* * Map ring pages to user space. */ -static int mon_bin_vma_fault(struct vm_fault *vmf) +static vm_fault_t mon_bin_vma_fault(struct vm_fault *vmf) { struct mon_reader_bin *rp = vmf->vma->vm_private_data; unsigned long offset, chunk_idx; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: mon: Change return type to vm_fault_t
On Mon, Apr 16, 2018 at 1:17 PM, Greg KH <gre...@linuxfoundation.org> wrote: > On Sun, Apr 15, 2018 at 04:10:08AM -0700, Matthew Wilcox wrote: >> On Sun, Apr 15, 2018 at 07:49:16AM +0200, Greg KH wrote: >> > On Sun, Apr 15, 2018 at 12:36:02AM +0530, Souptick Joarder wrote: >> > > Use new return type vm_fault_t for fault handler >> > > in struct vm_operations_struct. >> > >> > Why? >> >> commit 1c8f422059ae5da07db7406ab916203f9417e396 >> Author: Souptick Joarder <jrdr.li...@gmail.com> >> Date: Thu Apr 5 16:25:23 2018 -0700 >> >> mm: change return type to vm_fault_t >> >> The plan for these patches is to introduce the typedef, initially just >> as documentation ("These functions should return a VM_FAULT_ status"). >> We'll trickle the patches to individual drivers/filesystems in through >> the maintainers, as far as possible. Then we'll change the typedef to >> an unsigned int and break the compilation of any unconverted >> drivers/filesystems. >> >> vmf_insert_page(), vmf_insert_mixed() and vmf_insert_pfn() are three >> newly added functions. The various drivers/filesystems where return >> value of fault(), huge_fault(), page_mkwrite() and pfn_mkwrite() get >> converted, will need them. These functions will return correct >> VM_FAULT_ code based on err value. >> >> We've had bugs before where drivers returned -EFOO. And we have this >> silly inefficiency where vm_insert_xxx() return an errno which (afaict) >> every driver then converts into a VM_FAULT code. In many cases drivers >> failed to return correct VM_FAULT code value despite of vm_insert_xxx() >> fails. We have indentified and clean up all those existing bugs and >> silly inefficiencies in driver/filesystems by adding these three new >> inline wrappers. As mentioned above, we will trickle those patches to >> individual drivers/filesystems in through maintainers after these three >> wrapper functions are merged. > > Then put a summary of this type of thing in the original patch please! Ok, I will add it in change log and send v2. > > When a maintainer gets a patch with no context at all, the first > reaction is to just reject it (especially as many of these patches were > sent privately and did not go on any public mailing list, those all got > automatically dropped...) For few drivers only maintainers name is mentioned without any mailing list in Maintainer file. Not sure which mailing list to add for the same. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: mon: Change return type to vm_fault_t
Use new return type vm_fault_t for fault handler in struct vm_operations_struct. Signed-off-by: Souptick Joarder <jrdr.li...@gmail.com> Reviewed-by: Matthew Wilcox <mawil...@microsoft.com> --- drivers/usb/mon/mon_bin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 2761fad..34e866ad 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -1227,7 +1227,7 @@ static void mon_bin_vma_close(struct vm_area_struct *vma) /* * Map ring pages to user space. */ -static int mon_bin_vma_fault(struct vm_fault *vmf) +static vm_fault_t mon_bin_vma_fault(struct vm_fault *vmf) { struct mon_reader_bin *rp = vmf->vma->vm_private_data; unsigned long offset, chunk_idx; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: gadget: udc: bdc: Use dma_pool_zalloc
Any comment for this patch. On Wed, Feb 14, 2018 at 11:59 PM, Souptick Joarder <jrdr.li...@gmail.com> wrote: > Use dma_pool_zalloc instead of dma_pool_alloc + memset > > Signed-off-by: Souptick Joarder <jrdr.li...@gmail.com> > --- > drivers/usb/gadget/udc/bdc/bdc_ep.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c > b/drivers/usb/gadget/udc/bdc/bdc_ep.c > index f40d4c1..03149b9d 100644 > --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c > +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c > @@ -151,7 +151,7 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) > if (!bd_table) > goto fail; > > - bd_table->start_bd = dma_pool_alloc(bdc->bd_table_pool, > + bd_table->start_bd = dma_pool_zalloc(bdc->bd_table_pool, > GFP_ATOMIC, > ); > if (!bd_table->start_bd) { > @@ -167,7 +167,6 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) > (unsigned long long)bd_table->dma, prev_table); > > ep->bd_list.bd_table_array[index] = bd_table; > - memset(bd_table->start_bd, 0, bd_p_tab * sizeof(struct > bdc_bd)); > if (prev_table) > chain_table(prev_table, bd_table, bd_p_tab); > > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: gadget: udc: bdc: Use dma_pool_zalloc
Use dma_pool_zalloc instead of dma_pool_alloc + memset Signed-off-by: Souptick Joarder <jrdr.li...@gmail.com> --- drivers/usb/gadget/udc/bdc/bdc_ep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index f40d4c1..03149b9d 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -151,7 +151,7 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) if (!bd_table) goto fail; - bd_table->start_bd = dma_pool_alloc(bdc->bd_table_pool, + bd_table->start_bd = dma_pool_zalloc(bdc->bd_table_pool, GFP_ATOMIC, ); if (!bd_table->start_bd) { @@ -167,7 +167,6 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) (unsigned long long)bd_table->dma, prev_table); ep->bd_list.bd_table_array[index] = bd_table; - memset(bd_table->start_bd, 0, bd_p_tab * sizeof(struct bdc_bd)); if (prev_table) chain_table(prev_table, bd_table, bd_p_tab); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: host: ehci: Use dma_pool_zalloc()
Use dma_pool_zalloc() instead of dma_pool_alloc + memset Signed-off-by: Souptick Joarder <jrdr.li...@gmail.com> --- drivers/usb/host/ehci-mem.c | 3 +-- drivers/usb/host/ehci-sched.c | 6 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 21307d8..4c6c08b 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c @@ -73,10 +73,9 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags) if (!qh) goto done; qh->hw = (struct ehci_qh_hw *) - dma_pool_alloc(ehci->qh_pool, flags, ); + dma_pool_zalloc(ehci->qh_pool, flags, ); if (!qh->hw) goto fail; - memset(qh->hw, 0, sizeof *qh->hw); qh->qh_dma = dma; // INIT_LIST_HEAD (>qh_list); INIT_LIST_HEAD (>qtd_list); diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index e56db44..28e2a33 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -1287,7 +1287,7 @@ static void scan_intr(struct ehci_hcd *ehci) } else { alloc_itd: spin_unlock_irqrestore(>lock, flags); - itd = dma_pool_alloc(ehci->itd_pool, mem_flags, + itd = dma_pool_zalloc(ehci->itd_pool, mem_flags, _dma); spin_lock_irqsave(>lock, flags); if (!itd) { @@ -1297,7 +1297,6 @@ static void scan_intr(struct ehci_hcd *ehci) } } - memset(itd, 0, sizeof(*itd)); itd->itd_dma = itd_dma; itd->frame = NO_FRAME; list_add(>itd_list, >td_list); @@ -2081,7 +2080,7 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, } else { alloc_sitd: spin_unlock_irqrestore(>lock, flags); - sitd = dma_pool_alloc(ehci->sitd_pool, mem_flags, + sitd = dma_pool_zalloc(ehci->sitd_pool, mem_flags, _dma); spin_lock_irqsave(>lock, flags); if (!sitd) { @@ -2091,7 +2090,6 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, } } - memset(sitd, 0, sizeof(*sitd)); sitd->sitd_dma = sitd_dma; sitd->frame = NO_FRAME; list_add(>sitd_list, _sched->td_list); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb : Free previuos allocated memory when function call fails
Ok, I will drop this patch. On Tue, Nov 8, 2016 at 9:06 PM, Alan Stern <st...@rowland.harvard.edu> wrote: > On Tue, 8 Nov 2016, Souptick Joarder wrote: > >> In usb_parse_interface() when usb_parse_endpoint() fails it returns >> error whithout freeing alt->endpoint and we may have a memory leak. >> Fix this by freeing alt->endpoint before return. >> >> Signed-off-by: Souptick joarder <jrdr.li...@gmail.com> > > NAK. alt->endpoint is deallocated in usb_release_interface_cache() > even if usb_parse_endpoint() fails. > > Alan Stern > >> --- >> drivers/usb/core/config.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c >> index a2d90ac..6f599b6 100644 >> --- a/drivers/usb/core/config.c >> +++ b/drivers/usb/core/config.c >> @@ -492,8 +492,10 @@ static int usb_parse_interface(struct device *ddev, int >> cfgno, >> break; >> retval = usb_parse_endpoint(ddev, cfgno, inum, asnum, alt, >> num_ep, buffer, size); >> - if (retval < 0) >> + if (retval < 0) { >> + kfree(alt->endpoint); >> return retval; >> + } >> ++n; >> >> buffer += retval; >> > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb : Free previuos allocated memory when function call fails
In usb_parse_interface() when usb_parse_endpoint() fails it returns error whithout freeing alt->endpoint and we may have a memory leak. Fix this by freeing alt->endpoint before return. Signed-off-by: Souptick joarder <jrdr.li...@gmail.com> --- drivers/usb/core/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index a2d90ac..6f599b6 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -492,8 +492,10 @@ static int usb_parse_interface(struct device *ddev, int cfgno, break; retval = usb_parse_endpoint(ddev, cfgno, inum, asnum, alt, num_ep, buffer, size); - if (retval < 0) + if (retval < 0) { + kfree(alt->endpoint); return retval; + } ++n; buffer += retval; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html