[PATCH 05/25] USB OTG Langwell: Add pointer check in timer init function.

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

 



From: Hao Wu <hao.wu@xxxxxxxxx>

This patch adds pointer checking in timer initialization function
to handle the failure case which will cause the pointer to be NULL.

Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
Signed-off-by: Alan Cox <alan@xxxxxxxxxxxxxxx>
---

 drivers/usb/otg/langwell_otg.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)


diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
index 1b6124e..d808360 100644
--- a/drivers/usb/otg/langwell_otg.c
+++ b/drivers/usb/otg/langwell_otg.c
@@ -494,17 +494,27 @@ void langwell_otg_nsf_msg(unsigned long indicator)
 }
 
 /* Initialize timers */
-static void langwell_otg_init_timers(struct otg_hsm *hsm)
+static int langwell_otg_init_timers(struct otg_hsm *hsm)
 {
 	/* HSM used timers */
 	a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE,
 				(unsigned long)&hsm->a_wait_vrise_tmout);
+	if (a_wait_vrise_tmr == NULL)
+		return -ENOMEM;
 	a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS,
 				(unsigned long)&hsm->a_aidl_bdis_tmout);
+	if (a_aidl_bdis_tmr == NULL)
+		return -ENOMEM;
 	b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP,
 				(unsigned long)&hsm->b_se0_srp);
+	if (b_se0_srp_tmr == NULL)
+		return -ENOMEM;
 	b_srp_init_tmr = otg_timer_initializer(&set_tmout, TB_SRP_INIT,
 				(unsigned long)&hsm->b_srp_init_tmout);
+	if (b_srp_init_tmr == NULL)
+		return -ENOMEM;
+
+	return 0;
 }
 
 /* Free timers */
@@ -1987,7 +1997,11 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 	spin_lock_init(&langwell->lock);
 	spin_lock_init(&langwell->wq_lock);
 	INIT_LIST_HEAD(&active_timers);
-	langwell_otg_init_timers(&langwell->hsm);
+	retval = langwell_otg_init_timers(&langwell->hsm);
+	if (retval) {
+		dev_dbg(&pdev->dev, "Failed to init timers\n");
+		goto err;
+	}
 
 	if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
 				driver_name, langwell) != 0) {

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