usb: xhci: dbc: 2 smalll fixes for 'xhci_dbc_alloc_requests()'
Subsystems (3)
cover usb: xhci: dbc: 2 smalll fixes for 'xhci_dbc_alloc_requests()'
Christophe JAILLET (2):
usb: xhci: dbc: Simplify error handling in 'xhci_dbc_alloc_requests()'
usb: xhci: dbc: Use GFP_KERNEL instead of GFP_ATOMIC in
'xhci_dbc_alloc_requests()'
drivers/usb/host/xhci-dbgtty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 usb: xhci: dbc: Simplify error handling in 'xhci_dbc_alloc_requests()'
If the 'kmalloc()' fails, we need to undo the previous 'dbc_alloc_request()' call.
Because of the more similar function name, it is more logical to use 'dbc_free_request()' instead of 'xhci_dbc_free_req()'.
Both are equivalent here because:
static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) {
kfree(req->buf);
dbc_free_request(dep, req);
}
and 'req->buf' is known to be NULL at this point
--- drivers/usb/host/xhci-dbgtty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-dbgtty.c +1 -1
@@ -146,7 +146,7 @@ xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head, req->length =DBC_MAX_PACKET ; req->buf =kmalloc (req->length,GFP_KERNEL );if (!req->buf) { -xhci_dbc_free_req (dep, req); +dbc_free_request (dep, req);break ; }
Signature · 1 line
2.20.1
PATCH 2/2 usb: xhci: dbc: Use GFP_KERNEL instead of GFP_ATOMIC in 'xhci_dbc_alloc_requests()'
In reply to Christophe JAILLETThere is no need to use GFP_ATOMIC to allocate 'req'. GFP_KERNEL should be enough and is already used for another allocation juste a few lines below.
---
I've done my best to check if a spinlock can be hold when reaching this code. Apparently it is never the case.
But double check to be sure that it is not the kmalloc that should use GFP_ATOMIC.
--- drivers/usb/host/xhci-dbgtty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-dbgtty.c +1 -1
@@ -139,7 +139,7 @@ xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head,struct dbc_request *req;for (i =0 ; i <DBC_QUEUE_SIZE ; i++) { - req =dbc_alloc_request (dep,GFP_ATOMIC ); + req =dbc_alloc_request (dep,GFP_KERNEL );if (!req)break ;
Signature · 1 line
2.20.1
Quoted 10 lines · Christophe JAILLET
Christophe JAILLET (2):
usb: xhci: dbc: Simplify error handling in 'xhci_dbc_alloc_requests()'
usb: xhci: dbc: UseGFP_KERNELinstead ofGFP_ATOMICin'xhci_dbc_alloc_requests()'drivers/usb/host/xhci-dbgtty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks, adding to queue
-Mathias