File tree Expand file tree Collapse file tree 1 file changed +27
-10
lines changed Expand file tree Collapse file tree 1 file changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,14 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
153
153
tcb = nxsched_get_tcb (pid );
154
154
}
155
155
156
- up_perf_convert (tcb -> run_time , tp );
156
+ if (tcb != NULL )
157
+ {
158
+ up_perf_convert (tcb -> run_time , tp );
159
+ }
160
+ else
161
+ {
162
+ ret = - EFAULT ;
163
+ }
157
164
}
158
165
else if (clock_type == CLOCK_PROCESS_CPUTIME_ID )
159
166
{
@@ -174,18 +181,28 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
174
181
tcb = nxsched_get_tcb (pid );
175
182
}
176
183
177
- group = tcb -> group ;
178
- runtime = 0 ;
184
+ if (tcb != NULL )
185
+ {
186
+ group = tcb -> group ;
187
+ runtime = 0 ;
188
+
189
+ flags = enter_critical_section ();
190
+ for (i = group -> tg_nmembers - 1 ; i >= 0 ; i -- )
191
+ {
192
+ tcb = nxsched_get_tcb (group -> tg_members [i ]);
193
+ if (tcb != NULL )
194
+ {
195
+ runtime += tcb -> run_time ;
196
+ }
197
+ }
179
198
180
- flags = enter_critical_section ();
181
- for (i = group -> tg_nmembers - 1 ; i >= 0 ; i -- )
199
+ leave_critical_section (flags );
200
+ up_perf_convert (runtime , tp );
201
+ }
202
+ else
182
203
{
183
- tcb = nxsched_get_tcb (group -> tg_members [i ]);
184
- runtime += tcb -> run_time ;
204
+ ret = - EFAULT ;
185
205
}
186
-
187
- leave_critical_section (flags );
188
- up_perf_convert (runtime , tp );
189
206
}
190
207
#endif
191
208
else
You can’t perform that action at this time.
0 commit comments