From: Grazvydas Ignotas Date: Sun, 18 Jan 2009 16:58:37 +0000 (+0200) Subject: Add some error checking X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c01be10d0c157f62290b441db4d825c445cc3a7;p=pandora-wifi.git Add some error checking Avoid lock-up and NULL pointer crash --- diff --git a/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c b/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c index 8e0d8e0..2b3c900 100644 --- a/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c +++ b/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c @@ -160,6 +160,7 @@ void debug_module_init(void) else { console_printf_terminal("Debug module, error reading from device file.\n"); + exit(1); } } } diff --git a/sta_dk_4_0_4_32/CUDK/CLI/ticon.c b/sta_dk_4_0_4_32/CUDK/CLI/ticon.c index 363b34f..40a94d6 100644 --- a/sta_dk_4_0_4_32/CUDK/CLI/ticon.c +++ b/sta_dk_4_0_4_32/CUDK/CLI/ticon.c @@ -1263,6 +1263,11 @@ int init_driver( char *adapter_name, char *eeprom_file_name, char *init_file_nam } rc = IPC_DeviceIoControl(adapter_name, TIWLN_SET_INIT_INFO, init_info, req_size, NULL, 0, NULL); + if (rc != 0) + { + fprintf(stderr, "SET_INIT ioctl failed %s, %s\n", adapter_name, strerror(errno)); + goto init_driver_end; + } /*Send configMge start command as the cli is started*/ IPC_DeviceIoControl(adapter_name, TIWLN_DRIVER_STATUS_SET, &tmpData, sizeof(tiUINT32), NULL, 0, NULL); diff --git a/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c b/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c index 1829b90..59ca160 100644 --- a/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c +++ b/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c @@ -904,6 +904,24 @@ static void tiwlan_handle_control_requests( tiwlan_net_dev_t *drv ) /* DbgCB_Insert(0, DBG_MODULE_OS, DBG_TYPE_TASKLET, 1)*/ } +static void tiwlan_fail_requests( tiwlan_net_dev_t *drv ) +{ + while(!list_empty(&drv->request_q)) + { + struct list_head *entry = drv->request_q.next; + tiwlan_req_t *req = list_entry(entry, tiwlan_req_t, list); + unsigned long flags; + + spin_lock_irqsave(&drv->lock, flags); + list_del_init(entry); + spin_unlock_irqrestore(&drv->lock, flags); + + req->u.reply = -ENODEV; + if (req->u.req.reply_expected) + complete(&req->u.req.comp); + } +} + #ifdef DM_USE_WORKQUEUE static void tiwlan_irq_handler( struct work_struct *work ) { @@ -982,10 +1000,12 @@ static void tiwlan_tasklet_handler( unsigned long netdrv ) } /* don't call for "Handle interrupts, timers, ioctls" while recovery process */ - if (configMgr_areInputsFromOsDisabled(drv->adapter.CoreHalCtx) == TRUE) { + if (drv->adapter.CoreHalCtx == NULL || + configMgr_areInputsFromOsDisabled(drv->adapter.CoreHalCtx) == TRUE) { #ifdef CONFIG_ANDROID_POWER android_unlock_suspend( &drv->timer_wake_lock ); #endif + tiwlan_fail_requests(drv); return; }