[PATCH 1/4] staging: dwc2: fix potential null pointer access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We were testing hsotg pointer for null after we had already
dereferenced it

Reported-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
Signed-off-by: Paul Zimmerman <paulz@xxxxxxxxxxxx>
---
 drivers/staging/dwc2/hcd_ddma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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 @@ 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;
 	}
-- 
1.8.2.rc0.16.g20a599e

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux