staging: dwc2: fix potential null pointer access
We were testing hsotg pointer for null after we had already
dereferenced it
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/staging/dwc2/hcd_ddma.c b/drivers/staging/dwc2/hcd_ddma.c
index ab88f50..d2180b2 100644
--- a/drivers/staging/dwc2/hcd_ddma.c
+++ b/drivers/staging/dwc2/hcd_ddma.c
@@ -217,18 +217,18 @@
struct dwc2_host_chan *chan;
u16 i, j, inc;
+ if (!hsotg) {
+ pr_err("hsotg = %p", hsotg);
+ return;
+ }
+
if (!qh->channel) {
dev_err(hsotg->dev, "qh->channel = %p", qh->channel);
return;
}
- if (!hsotg) {
- dev_err(hsotg->dev, "------hsotg = %p", hsotg);
- return;
- }
-
if (!hsotg->frame_list) {
- dev_err(hsotg->dev, "-------hsotg->frame_list = %p",
+ dev_err(hsotg->dev, "hsotg->frame_list = %p",
hsotg->frame_list);
return;
}