kernel-shark: sched-plugin: Initialize plugin_sched_context_handler to zeros
PATCH 1/1 kernel-shark: sched-plugin: Initialize plugin_sched_context_handler to zeros
From: "Steven Rostedt (VMware)" <[email protected]>
Now that the sched plugin only requires a single wakeup event to process the wakeup latency boxes, there's no guarantee that all the wakeup events saved in plugin_sched_context_handler will be initialized.
Allocate plugin_sched_context_handler to zeros with calloc() instead of malloc() to make sure the pointers it has are NULL and not left uninitialized.
--- kernel-shark/src/plugins/sched_events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/src/plugins/sched_events.c +1 -1
@@ -49,7 +49,7 @@ static bool plugin_sched_init_context(struct kshark_context *kshark_ctx)assert (plugin_sched_context_handler ==NULL ); plugin_sched_context_handler = -malloc (sizeof (*plugin_sched_context_handler)); +calloc (1 ,sizeof (*plugin_sched_context_handler));if (!plugin_sched_context_handler) {fprintf (stderr,"Failed to allocate memory for plugin_sched_context.\n" );
Signature · 1 line
2.20.1
Quoted 22 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
Now that the sched plugin only requires a single wakeup event to process the wakeup latency boxes, there's no guarantee that all the wakeup events saved in
plugin_sched_context_handlerwill be initialized.Allocate
plugin_sched_context_handlerto zeros withcalloc()instead ofmalloc()to make sure the pointers it has are NULL and not left uninitialized.Fixes e50d3bbfc9a4 ("kernel-shark: Add sched_waking event processing to sched_waking")Signed-off-by Steven Rostedt (VMware) <[email protected]>--- kernel-shark/src/plugins/sched_events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel-shark/src/plugins/sched_events.c +0
-0
kernel-shark/src/plugins/sched_events.c static bool plugin_sched_init_context(struct kshark_context *kshark_ctx) · line 55
Quoted 8 lines
kernel-shark/src/plugins/sched_events.c +1
-1@@ -49,7 +49,7 @@ static bool plugin_sched_init_context(struct kshark_context *kshark_ctx)assert (plugin_sched_context_handler ==NULL ); plugin_sched_context_handler = -malloc (sizeof (*plugin_sched_context_handler)); +calloc (1 ,sizeof (*plugin_sched_context_handler));if (!plugin_sched_context_handler) {fprintf (stderr,"Failed to allocate memory for plugin_sched_context.\n" );
makes perfect sense.
Thanks!
Yordan
Quoted 11 lines · On Thu, 14 Feb 2019 16:33:03 +0000 Yordan Karadzhov <[email protected]>…
Quoted 10 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
Now that the sched plugin only requires a single wakeup event to process the wakeup latency boxes, there's no guarantee that all the wakeup events saved in
plugin_sched_context_handlerwill be initialized.Allocate
plugin_sched_context_handlerto zeros withcalloc()instead ofmalloc()to make sure the pointers it has are NULL and not left uninitialized.
Quoted 5 lines
Quoted 3 lines
Fixes e50d3bbfc9a4 ("kernel-shark: Add sched_waking event processing to sched_waking")Signed-off-by Steven Rostedt (VMware) <[email protected]>---
makes perfect sense.
Thanks Yordan,
Can you reply with an official "Reviewed-by" tag?
-- Steve
Quoted 22 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
Now that the sched plugin only requires a single wakeup event to process the wakeup latency boxes, there's no guarantee that all the wakeup events saved in
plugin_sched_context_handlerwill be initialized.Allocate
plugin_sched_context_handlerto zeros withcalloc()instead ofmalloc()to make sure the pointers it has are NULL and not left uninitialized.Fixes e50d3bbfc9a4 ("kernel-shark: Add sched_waking event processing to sched_waking")Signed-off-by Steven Rostedt (VMware) <[email protected]>--- kernel-shark/src/plugins/sched_events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel-shark/src/plugins/sched_events.c +0
-0
kernel-shark/src/plugins/sched_events.c static bool plugin_sched_init_context(struct kshark_context *kshark_ctx) · line 55
Quoted 8 lines
kernel-shark/src/plugins/sched_events.c +1
-1@@ -49,7 +49,7 @@ static bool plugin_sched_init_context(struct kshark_context *kshark_ctx)assert (plugin_sched_context_handler ==NULL ); plugin_sched_context_handler = -malloc (sizeof (*plugin_sched_context_handler)); +calloc (1 ,sizeof (*plugin_sched_context_handler));if (!plugin_sched_context_handler) {fprintf (stderr,"Failed to allocate memory for plugin_sched_context.\n" );