staging: dwc2: fix potential null pointer access
authorPaul Zimmerman <Paul.Zimmerman@synopsys.com>
Mon, 22 Apr 2013 21:00:16 +0000 (14:00 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Apr 2013 17:37:55 +0000 (10:37 -0700)
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>
drivers/staging/dwc2/hcd_ddma.c

index ab88f5069183bccd98c2fac61b22bc105b3edacc..d2180b275f7aa00863180533c1b4c5ecc6435b5a 100644 (file)
@@ -217,18 +217,18 @@ static void dwc2_update_frame_list(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
        struct dwc2_host_chan *chan;
        u16 i, j, inc;
 
-       if (!qh->channel) {
-               dev_err(hsotg->dev, "qh->channel = %p", qh->channel);
+       if (!hsotg) {
+               pr_err("hsotg = %p", hsotg);
                return;
        }
 
-       if (!hsotg) {
-               dev_err(hsotg->dev, "------hsotg = %p", hsotg);
+       if (!qh->channel) {
+               dev_err(hsotg->dev, "qh->channel = %p", qh->channel);
                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;
        }