xiaoxiang781216 commented on code in PR #10585:
URL: https://github.com/apache/nuttx/pull/10585#discussion_r1323038224


##########
drivers/power/pm/pm_procfs.c:
##########
@@ -114,6 +114,8 @@ static int     pm_rewinddir(FAR struct fs_dirent_s *dir);
 
 static int     pm_stat(FAR const char *relpath, FAR struct stat *buf);
 
+static int     pm_path_validate(FAR const char *relpath);

Review Comment:
   ```suggestion
   static int     pm_get_file_index(FAR const char *relpath);
   ```



##########
drivers/power/pm/pm_procfs.c:
##########
@@ -181,6 +203,12 @@ static int pm_open(FAR struct file *filep, FAR const char 
*relpath,
       return -EACCES;
     }
 
+  relpath += strlen("pm/");
+  if (pm_path_validate(relpath) < 0)

Review Comment:
   ```suggestion
     i = pm_path_validate(relpath);
     if (i < 0)
   ```
   and change line 221 to 231:
   ```
     pmfile->read = g_pm_files[i].read;
     pmfile->domain = atoi(relpath + strlen(g_pm_files[i].name));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to