misc: fix crash using tracedump plugin with socket API clients 56/37856/1
authorArthur de Kerhor <arthurdekerhor@gmail.com>
Thu, 22 Dec 2022 18:48:05 +0000 (19:48 +0100)
committerArthur de Kerhor <arthurdekerhor@gmail.com>
Thu, 22 Dec 2022 18:48:05 +0000 (19:48 +0100)
Type: fix
Signed-off-by: Arthur de Kerhor <arthurdekerhor@gmail.com>
Change-Id: I208724a515c9a38c4032f101bdf73aa87b1c13be

src/plugins/tracedump/tracedump.c

index 17b9a42..0f1612c 100644 (file)
@@ -213,12 +213,15 @@ vl_api_trace_dump_t_handler (vl_api_trace_dump_t * mp)
   iterator_position = clib_net_to_host_u32 (mp->position);
   max_records = clib_net_to_host_u32 (mp->max_records);
 
-  /* Don't overflow the existing queue space. */
-  svm_queue_t *q = rp->vl_input_queue;
-  u32 queue_slots_available = q->maxsize - q->cursize;
-  int chunk = (queue_slots_available > 0) ? queue_slots_available - 1 : 0;
-  if (chunk < max_records)
-    max_records = chunk;
+  /* Don't overflow the existing queue space for shared memory API clients. */
+  if (rp->vl_input_queue)
+    {
+      svm_queue_t *q = rp->vl_input_queue;
+      u32 queue_slots_available = q->maxsize - q->cursize;
+      int chunk = (queue_slots_available > 0) ? queue_slots_available - 1 : 0;
+      if (chunk < max_records)
+       max_records = chunk;
+    }
 
   /* Need a fresh cache for this client? */
   if (vec_len (client_trace_cache) == 0