From f981b1d98eb4c3cbc9cd453175de4a2862c5c189 Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Tue, 01 Mar 2016 06:24:16 +0000 Subject: PD#116677: fix system server crash in auto-reboot Thread check connection may crash by NULL pointer if port status is under updating during 2 IOCTRL operations. We need sync these operations to avoid this bug. Change-Id: If3cd49a1c6afd623830b74a17e0361757dd24608 --- diff --git a/Android.mk b/Android.mk index cb9f290..aa75ea8 100644 --- a/Android.mk +++ b/Android.mk @@ -20,7 +20,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := hdmi_cec.c LOCAL_PRELINK_MODULE := false LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_SHARED_LIBRARIES := liblog libcutils libnativehelper LOCAL_MODULE := hdmi_cec.amlogic LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) diff --git a/hdmi_cec.c b/hdmi_cec.c index c6cc38a..b6edc32 100644 --- a/hdmi_cec.c +++ b/hdmi_cec.c @@ -129,7 +129,7 @@ static void check_connect_status(struct aml_cec_hal *hal) hdmi_event_t event; prev_status = hal->con_status; - for (i = 0; i < hal->total_port; i++) { + for (i = 0; i < hal->total_port && hal->port_data != NULL; i++) { port = hal->port_data[i].port_id; ret = ioctl(hal_info->fd, CEC_IOC_GET_CONNECT_STATUS, &port); if (ret) { @@ -465,7 +465,6 @@ static void cec_get_port_info(const struct hdmi_cec_device* dev, D("dev:%p, total port:%d\n", dev, *total); if (*total > MAX_PORT) *total = MAX_PORT; - hal_info->total_port = *total; hal_info->port_data = malloc(sizeof(struct hdmi_port_info) * (*total)); if (!hal_info->port_data) { E("alloc port_data failed\n"); @@ -482,6 +481,7 @@ static void cec_get_port_info(const struct hdmi_cec_device* dev, hal_info->port_data[i].physical_address); } *list = hal_info->port_data; + hal_info->total_port = *total; } /* -- cgit