[PATCH 3/5] usb: renesas_usbhs: prevent NULL pointer crash

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

 



usbhs_status_get_each_irq/usbhs_irq_callback_update might be called
with mod == NULL

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 drivers/usb/renesas_usbhs/mod.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 73604a1..d0f5f67 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -179,15 +179,17 @@ static void usbhs_status_get_each_irq(struct usbhs_priv *priv,
 	state->intsts0 = usbhs_read(priv, INTSTS0);
 	state->intsts1 = usbhs_read(priv, INTSTS1);
 
-	state->brdysts = usbhs_read(priv, BRDYSTS);
-	state->nrdysts = usbhs_read(priv, NRDYSTS);
-	state->bempsts = usbhs_read(priv, BEMPSTS);
-
 	state->dvstctr = usbhs_read(priv, DVSTCTR);
 
 	/* mask */
-	state->bempsts &= mod->irq_bempsts;
-	state->brdysts &= mod->irq_brdysts;
+	if (mod) {
+		state->brdysts = usbhs_read(priv, BRDYSTS);
+		state->nrdysts = usbhs_read(priv, NRDYSTS);
+		state->bempsts = usbhs_read(priv, BEMPSTS);
+
+		state->bempsts &= mod->irq_bempsts;
+		state->brdysts &= mod->irq_brdysts;
+	}
 }
 
 /*
@@ -259,17 +261,19 @@ void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod)
 	 * but "mod->irq_dev_state" will be called.
 	 */
 
-	if (mod->irq_ctrl_stage)
-		intenb0 |= CTRE;
+	if (mod) {
+		if (mod->irq_ctrl_stage)
+			intenb0 |= CTRE;
 
-	if (mod->irq_empty && mod->irq_bempsts) {
-		usbhs_write(priv, BEMPENB, mod->irq_bempsts);
-		intenb0 |= BEMPE;
-	}
+		if (mod->irq_empty && mod->irq_bempsts) {
+			usbhs_write(priv, BEMPENB, mod->irq_bempsts);
+			intenb0 |= BEMPE;
+		}
 
-	if (mod->irq_ready && mod->irq_brdysts) {
-		usbhs_write(priv, BRDYENB, mod->irq_brdysts);
-		intenb0 |= BRDYE;
+		if (mod->irq_ready && mod->irq_brdysts) {
+			usbhs_write(priv, BRDYENB, mod->irq_brdysts);
+			intenb0 |= BRDYE;
+		}
 	}
 
 	usbhs_write(priv, INTENB0, intenb0);
-- 
1.7.1

--
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