kernel/os: os_dev_add check to see if device is already present
If the device is already present in the global list,
calling os_dev_add() can potentially result in an incorrect
list. Fix this by checking for the device when the list
is traversed.
@@ -64,7 +64,10 @@ os_dev_add(struct os_dev *dev)
*/
prev_dev = NULL;
STAILQ_FOREACH(cur_dev, &g_os_dev_list, od_next) {
- if (dev->od_stage < cur_dev->od_stage ||
+ if (dev == cur_dev) {
+ /* Do nothing */
+ return 0;
+ } else if (dev->od_stage < cur_dev->od_stage ||
((dev->od_stage == cur_dev->od_stage) &&
(dev->od_priority < cur_dev->od_priority))) {
break;
