[PATCH 1/2] kernel-shark-qt: Deal with the "no tasks" case in kshark_get_task_pids()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kshark_get_task_pids() should not return a "memory allocation" error
in the case when it is called before having trace data loaded.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
---
 kernel-shark-qt/src/libkshark.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c
index 668b6df..75b88c9 100644
--- a/kernel-shark-qt/src/libkshark.c
+++ b/kernel-shark-qt/src/libkshark.c
@@ -303,6 +303,12 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids)
 		}
 	}
 
+	if (!pid_count) {
+		free(*pids);
+		*pids = NULL;
+		return pid_count;
+	}
+
 	temp_pids = realloc(*pids, pid_count * sizeof(int));
 	if (!temp_pids)
 		goto fail;
-- 
2.17.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux