From 9368373fd9dfb90f4c566fc849d6412b5add5695 Mon Sep 17 00:00:00 2001 From: "Liu, Xinwu" Date: Fri, 19 Oct 2018 12:50:38 +0800 Subject: [PATCH] tools: acrn-crashlog: check the pointer after getting sender get_sender_from_name would return NULL if the name of sender is not configured in acrnprobe.xml. This patch check the return value of it. Tracked-On: #1024 Signed-off-by: Liu, Xinwu Reviewed-by: Huang Yonghua Acked-by: Chen Gang --- tools/acrn-crashlog/acrnprobe/sender.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/acrn-crashlog/acrnprobe/sender.c b/tools/acrn-crashlog/acrnprobe/sender.c index e43ed1061..1818c2990 100644 --- a/tools/acrn-crashlog/acrnprobe/sender.c +++ b/tools/acrn-crashlog/acrnprobe/sender.c @@ -463,7 +463,7 @@ free_class: static void telemd_send_uptime(void) { - struct sender_t *telemd; + struct sender_t *telemd = get_sender_by_name("telemd"); struct uptime_t *uptime; char *class; char boot_time[UPTIME_SIZE]; @@ -472,12 +472,14 @@ static void telemd_send_uptime(void) static int uptime_hours; static int loop_uptime_event = 1; + if (!telemd) + return; + ret = get_uptime_string(boot_time, &hours); if (ret < 0) { LOGE("cannot get uptime - %s\n", strerror(-ret)); return; } - telemd = get_sender_by_name("telemd"); uptime = telemd->uptime; uptime_hours = atoi(uptime->eventhours); if (hours / uptime_hours >= loop_uptime_event) { @@ -505,12 +507,14 @@ static void telemd_send_uptime(void) static void telemd_send_reboot(void) { - struct sender_t *telemd; + struct sender_t *telemd = get_sender_by_name("telemd"); char *class; char reason[REBOOT_REASON_SIZE]; int ret; - telemd = get_sender_by_name("telemd"); + if (!telemd) + return; + if (swupdated(telemd)) { char *content;