usb: gadget: dwc2: fix zlp handling
authorAndrzej Pietrasiewicz <andrzej.p@collabora.com>
Mon, 1 Apr 2019 10:50:45 +0000 (12:50 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 6 Jun 2019 10:51:57 +0000 (13:51 +0300)
commit066cfd0770aba8a9ac79b59d99530653885d919d
tree5aaba57969f52b5424fb50db399615b99bb59bc6
parent4faf3b36553a0a5304f58ee3a620e659739a2e20
usb: gadget: dwc2: fix zlp handling

The patch 10209abe87f5ebfd482a00323f5236d6094d0865
usb: dwc2: gadget: Add scatter-gather mode

avoided a NULL pointer dereference (hs_ep->req == NULL) by
calling dwc2_gadget_fill_nonisoc_xfer_dma_one() directly instead of through
the dwc2_gadget_config_nonisoc_xfer_ddma() wrapper, which unconditionally
dereferenced the said pointer.

However, this was based on an incorrect assumption that in the context of
dwc2_hsotg_program_zlp() the pointer is always NULL, which is not the case.
The result were SB CV MSC tests failing starting from Test Case 6.

Instead, this patch reverts to calling the wrapper and adds a check for
the pointer being NULL inside the wrapper.

Fixes: 10209abe87f5 (usb: dwc2: gadget: Add scatter-gather mode)
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc2/gadget.c