aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs/mod.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-04-28 03:41:07 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-29 20:24:34 -0400
commit5ea68d541df200d10a373c06f945f98225c2486b (patch)
tree57957c68bd0b7af0a4d4387409b8e0fcbd2fcf1b /drivers/usb/renesas_usbhs/mod.c
parent6e267da8f10b1a6551b6c4dee3779f6f56e2644d (diff)
usb: renesas_usbhs: prevent NULL pointer crash
usbhs_status_get_each_irq/usbhs_irq_callback_update might be called with mod == NULL Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/renesas_usbhs/mod.c')
-rw-r--r--drivers/usb/renesas_usbhs/mod.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 73604a1d6843..d0f5f67e0749 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,
179 state->intsts0 = usbhs_read(priv, INTSTS0); 179 state->intsts0 = usbhs_read(priv, INTSTS0);
180 state->intsts1 = usbhs_read(priv, INTSTS1); 180 state->intsts1 = usbhs_read(priv, INTSTS1);
181 181
182 state->brdysts = usbhs_read(priv, BRDYSTS);
183 state->nrdysts = usbhs_read(priv, NRDYSTS);
184 state->bempsts = usbhs_read(priv, BEMPSTS);
185
186 state->dvstctr = usbhs_read(priv, DVSTCTR); 182 state->dvstctr = usbhs_read(priv, DVSTCTR);
187 183
188 /* mask */ 184 /* mask */
189 state->bempsts &= mod->irq_bempsts; 185 if (mod) {
190 state->brdysts &= mod->irq_brdysts; 186 state->brdysts = usbhs_read(priv, BRDYSTS);
187 state->nrdysts = usbhs_read(priv, NRDYSTS);
188 state->bempsts = usbhs_read(priv, BEMPSTS);
189
190 state->bempsts &= mod->irq_bempsts;
191 state->brdysts &= mod->irq_brdysts;
192 }
191} 193}
192 194
193/* 195/*
@@ -259,17 +261,19 @@ void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod)
259 * but "mod->irq_dev_state" will be called. 261 * but "mod->irq_dev_state" will be called.
260 */ 262 */
261 263
262 if (mod->irq_ctrl_stage) 264 if (mod) {
263 intenb0 |= CTRE; 265 if (mod->irq_ctrl_stage)
266 intenb0 |= CTRE;
264 267
265 if (mod->irq_empty && mod->irq_bempsts) { 268 if (mod->irq_empty && mod->irq_bempsts) {
266 usbhs_write(priv, BEMPENB, mod->irq_bempsts); 269 usbhs_write(priv, BEMPENB, mod->irq_bempsts);
267 intenb0 |= BEMPE; 270 intenb0 |= BEMPE;
268 } 271 }
269 272
270 if (mod->irq_ready && mod->irq_brdysts) { 273 if (mod->irq_ready && mod->irq_brdysts) {
271 usbhs_write(priv, BRDYENB, mod->irq_brdysts); 274 usbhs_write(priv, BRDYENB, mod->irq_brdysts);
272 intenb0 |= BRDYE; 275 intenb0 |= BRDYE;
276 }
273 } 277 }
274 278
275 usbhs_write(priv, INTENB0, intenb0); 279 usbhs_write(priv, INTENB0, intenb0);