Re: [PATCH 3/4] rtems-debugger-threads.c: Fix Coverity Dereference before null check

2021-02-11 Thread Chris Johns
On 12/2/21 7:27 am, Ryan Long wrote:
> Fixes CID #1468681, 1468690, and 1468694 by checking if threads is null in
> the rtems_debugger_thread_find_index, rtems_debugger_thread_system_resume,
> and rtems_debugger_thread_continue_all functions.

Looks good. Thanks

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/4] rtems-debugger-threads.c: Fix Coverity Dereference before null check

2021-02-11 Thread Ryan Long
Fixes CID #1468681, 1468690, and 1468694 by checking if threads is null in
the rtems_debugger_thread_find_index, rtems_debugger_thread_system_resume,
and rtems_debugger_thread_continue_all functions.
---
 cpukit/libdebugger/rtems-debugger-threads.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-threads.c 
b/cpukit/libdebugger/rtems-debugger-threads.c
index 84a9faa..5b96e5f 100644
--- a/cpukit/libdebugger/rtems-debugger-threads.c
+++ b/cpukit/libdebugger/rtems-debugger-threads.c
@@ -148,9 +148,9 @@ int
 rtems_debugger_thread_find_index(rtems_id id)
 {
   rtems_debugger_threads* threads = rtems_debugger->threads;
-  rtems_debugger_thread*  current = rtems_debugger_thread_current(threads);
   int r = -1;
   if (threads != NULL) {
+rtems_debugger_thread* current = rtems_debugger_thread_current(threads);
 size_t i;
 for (i = 0; i < threads->current.level; ++i) {
   if (id == 0 || current[i].id == id) {
@@ -347,8 +347,11 @@ rtems_debugger_thread_system_resume(bool detaching)
   rtems_debugger_threads* threads = rtems_debugger->threads;
   rtems_debugger_thread*  current;
   int r = 0;
+  if (threads == NULL) {
+return r;
+  }
   current = rtems_debugger_thread_current(threads);
-  if (threads != NULL && current != NULL) {
+  if (current != NULL) {
 size_t i;
 if (rtems_debugger_verbose())
   rtems_debugger_printf("rtems-db: sys:: resuming\n");
@@ -430,8 +433,13 @@ rtems_debugger_thread_continue_all(void)
   rtems_debugger_threads* threads = rtems_debugger->threads;
   rtems_debugger_thread*  current;
   int r = 0;
+  if (threads == NULL) {
+r = -1;
+errno = EIO;
+return r;
+  }
   current = rtems_debugger_thread_current(threads);
-  if (threads != NULL && current != NULL) {
+  if (current != NULL) {
 size_t i;
 for (i = 0; i < threads->current.level; ++i) {
   rtems_debugger_thread* thread = [i];
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel