The logic in dwc2_hcd_qtd_add() was a bit messy, and one of the
error exit paths was broken. Fix it up.
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Tested-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ if (!urb->priv)
+ return NULL;
+
/* Allocate memory */
qh = kzalloc(sizeof(*qh), mem_flags);
if (!qh)
/* Allocate memory */
qh = kzalloc(sizeof(*qh), mem_flags);
if (!qh)
struct dwc2_hcd_urb *urb = qtd->urb;
unsigned long flags;
int allocated = 0;
struct dwc2_hcd_urb *urb = qtd->urb;
unsigned long flags;
int allocated = 0;
/*
* Get the QH which holds the QTD-list to insert to. Create QH if it
/*
* Get the QH which holds the QTD-list to insert to. Create QH if it
}
spin_lock_irqsave(&hsotg->lock, flags);
}
spin_lock_irqsave(&hsotg->lock, flags);
retval = dwc2_hcd_qh_add(hsotg, *qh);
retval = dwc2_hcd_qh_add(hsotg, *qh);
- if (retval && allocated) {
+ if (retval)
+ goto fail;
+
+ qtd->qh = *qh;
+ list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list);
+ spin_unlock_irqrestore(&hsotg->lock, flags);
+
+ return 0;
+
+fail:
+ if (allocated) {
struct dwc2_qtd *qtd2, *qtd2_tmp;
struct dwc2_qh *qh_tmp = *qh;
struct dwc2_qtd *qtd2, *qtd2_tmp;
struct dwc2_qh *qh_tmp = *qh;
spin_unlock_irqrestore(&hsotg->lock, flags);
dwc2_hcd_qh_free(hsotg, qh_tmp);
} else {
spin_unlock_irqrestore(&hsotg->lock, flags);
dwc2_hcd_qh_free(hsotg, qh_tmp);
} else {
- qtd->qh = *qh;
- list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list);
spin_unlock_irqrestore(&hsotg->lock, flags);
}
spin_unlock_irqrestore(&hsotg->lock, flags);
}