USB SL811HS HCD: Fix memory leak in sl811h_urb_enqueue()
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / sl811-hcd.c
index bcf9f0e809dedbd194d34cd6e2a39639a1ff94ea..2e9602a10e9bfe0ab267cb2bb09995f4f23b2796 100644 (file)
@@ -813,8 +813,11 @@ static int sl811h_urb_enqueue(
 #endif
 
        /* avoid all allocations within spinlocks */
-       if (!hep->hcpriv)
+       if (!hep->hcpriv) {
                ep = kzalloc(sizeof *ep, mem_flags);
+               if (ep == NULL)
+                       return -ENOMEM;
+       }
 
        spin_lock_irqsave(&sl811->lock, flags);
 
@@ -858,6 +861,7 @@ static int sl811h_urb_enqueue(
                        DBG("dev %d ep%d maxpacket %d\n",
                                udev->devnum, epnum, ep->maxpacket);
                        retval = -EINVAL;
+                       kfree(ep);
                        goto fail;
                }