On Fri, 25 Dec 2015, Steinar H. Gunderson wrote: > On Fri, Dec 25, 2015 at 09:50:50AM +0100, Oliver Neukum wrote: > > > + ret = usbfs_increase_memory_usage(size + sizeof(struct usb_memory)); > > > + if (ret) { > > > + module_put(THIS_MODULE); > > > + return ret; > > > + } > > > > Could you do the error handling in a unified manner with "goto"? > > Yes and no. I couldn't do it fully unified; note the error path below that > uses usbfs_decrease_memory_usage() instead. I could do it sort-of-unified, > but it ended up being one of those label cascades, of course: > > return 0; > > error_free_usbm: > kfree(usbm); > error_decrease_mem: > usbfs_decrease_memory_usage(size + sizeof(struct usb_memory)); > error_module_put: > module_put(THIS_MODULE); > return ret; That's okay; lots of drivers do this and people expect it. It also reduces the total amount of code. > > > + mem = usb_alloc_coherent(ps->dev, size, GFP_KERNEL, &dma_handle); > > Shouldn't this be GFP_USER to let limits apply? > > This I don't really know anything about. Alan? There doesn't appear to be very much difference between them. As far as I can tell from the documentation in include/linux/gfp.h, GPF_USER would indeed be more appropriate. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html