Add some error checking
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 18 Jan 2009 16:58:37 +0000 (18:58 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Sat, 24 Jan 2009 21:55:02 +0000 (23:55 +0200)
Avoid lock-up and NULL pointer crash

sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c
sta_dk_4_0_4_32/CUDK/CLI/ticon.c
sta_dk_4_0_4_32/pform/linux/src/esta_drv.c

index 8e0d8e0..2b3c900 100644 (file)
@@ -160,6 +160,7 @@ void debug_module_init(void)
                        else
                        {
                                console_printf_terminal("Debug module, error reading from device file.\n");
+                               exit(1);
                        }
                }
        }
index 363b34f..40a94d6 100644 (file)
@@ -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);
index 1829b90..59ca160 100644 (file)
@@ -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;
        }