usb: xhci: dbc: Simplify error handling in 'xhci_dbc_alloc_requests()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 30 Aug 2019 13:39:13 +0000 (16:39 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Sep 2019 13:49:11 +0000 (15:49 +0200)
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

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/1567172356-12915-2-git-send-email-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-dbgtty.c

index aff79ff5aba483f15557aaa007ad9d36ee68a4f0..845939f8a0b8ee3e83e31604489ebc51cbf51c88 100644 (file)
@@ -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;
                }