OSDN Git Service

w500: fix loop segfault in input devices list
authorTanguy Pruvot <tanguy.pruvot@gmail.com>
Fri, 13 Jun 2014 21:44:41 +0000 (23:44 +0200)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 23 Jun 2014 15:58:10 +0000 (23:58 +0800)
w500_sensor.c

index a945acb..d1a8839 100644 (file)
@@ -67,8 +67,7 @@ static int open_accel_sensor(void)
                 * for our driver.
                 */
                ALOGD("%s[%i] Looping over all eventXX...", __func__, __LINE__);
-               do {
-                       de = readdir(dir);
+               while ((de = readdir(dir))) {
                        if (de->d_name[0] != 'e')
                                continue;
                        memset(name, 0, PATH_MAX);
@@ -101,7 +100,7 @@ static int open_accel_sensor(void)
                        }
 
                        close(fd);
-               } while (de != NULL);
+               }
 
                ALOGD("%s[%i] stop loop and closing directory",
                        __func__, __LINE__);