From 73cff27fa4bfd65e4a1a08b28b741efcd6a07dc3 Mon Sep 17 00:00:00 2001 From: zhizhimeimei6 Date: Thu, 17 Feb 2022 10:04:05 +0800 Subject: [PATCH 1/3] zerohung: fix CROSS_COMPILE error ohos inclusion category: bugfix issue: #I4U4X3 CVE: NA ----------------- Using notifier_call replaces the orignal way Signed-off-by: zhizhimeimei6 --- .../zerohung/watchpoint/hung_wp_screen.c | 36 ++++++++++++++++--- drivers/video/backlight/backlight.c | 10 ------ include/dfx/hung_wp_screen.h | 2 -- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/staging/zerohung/watchpoint/hung_wp_screen.c b/drivers/staging/zerohung/watchpoint/hung_wp_screen.c index 9b295fed067d..e76fe54f9d20 100644 --- a/drivers/staging/zerohung/watchpoint/hung_wp_screen.c +++ b/drivers/staging/zerohung/watchpoint/hung_wp_screen.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -61,7 +63,7 @@ static unsigned int headevt; static int *check_off_point; struct work_struct powerkeyevent_sendwork; struct work_struct lpressevent_sendwork; - +static struct notifier_block hung_wp_screen_setblank_ncb; static void zrhung_lpressevent_send_work(struct work_struct *work) { @@ -157,13 +159,19 @@ static void zrhung_powerkeyevent_handler(void) zrhung_new_powerkeyevent(curtime); } -void hung_wp_screen_setblank(int blank) +static int hung_wp_screen_setblank(struct notifier_block *self, unsigned long event, void *data) { unsigned long flags; + struct fb_event *evdata = data; + int blank; if (!init_done) - return; + return 0; + if (event != FB_EVENT_BLANK) + return 0; + + blank = *(int *)evdata->data; spin_lock_irqsave(&(g_hung_data.lock), flags); g_hung_data.fb_blank = blank; if (((g_hung_data.check_id == ZRHUNG_WP_SCREENON) && (blank == 0)) || @@ -173,6 +181,8 @@ void hung_wp_screen_setblank(int blank) g_hung_data.check_id = ZRHUNG_WP_NONE; } spin_unlock_irqrestore(&(g_hung_data.lock), flags); + + return 0; } static void hung_wp_screen_send_work(struct work_struct *work) @@ -212,8 +222,6 @@ static void hung_wp_screen_start(int check_id) g_hung_data.timer.expires = jiffies + msecs_to_jiffies(DEFAULT_TIMEOUT * TIME_CONVERT_UNIT); add_timer(&g_hung_data.timer); pr_info("going to check ID=%d timeout=%d\n", check_id, DEFAULT_TIMEOUT); - - return; } void hung_wp_screen_powerkey_ncb(int event) @@ -271,12 +279,30 @@ static int __init hung_wp_screen_init(void) INIT_WORK(&powerkeyevent_sendwork, zrhung_powerkeyevent_send_work); INIT_WORK(&lpressevent_sendwork, zrhung_lpressevent_send_work); + hung_wp_screen_setblank_ncb.notifier_call = hung_wp_screen_setblank; + fb_register_client(&hung_wp_screen_setblank_ncb); + init_done = true; pr_info("%s done\n", __func__); return 0; } +static void __exit hung_wp_screen_exit(void) +{ + fb_unregister_client(&hung_wp_screen_setblank_ncb); + + cancel_work_sync(&lpressevent_sendwork); + cancel_work_sync(&powerkeyevent_sendwork); + cancel_work_sync(&g_hung_data.send_work); + + destroy_workqueue(g_hung_data.workq); + + del_timer_sync(&g_hung_data.timer); + del_timer_sync(&g_hung_data.long_press_timer); +} + module_init(hung_wp_screen_init); +module_exit(hung_wp_screen_exit); MODULE_AUTHOR("OHOS"); MODULE_DESCRIPTION("Reporting the frozen screen alarm event"); diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 4bda5fc5e624..537fe1b376ad 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -22,10 +22,6 @@ #include #endif -#ifdef CONFIG_DFX_ZEROHUNG -#include -#endif - /** * DOC: overview * @@ -124,9 +120,6 @@ static int fb_notifier_callback(struct notifier_block *self, bd->props.state &= ~BL_CORE_FBBLANK; bd->props.fb_blank = FB_BLANK_UNBLANK; backlight_update_status(bd); -#ifdef CONFIG_DFX_ZEROHUNG - hung_wp_screen_setblank(fb_blank); -#endif } } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { bd->fb_bl_on[node] = false; @@ -134,9 +127,6 @@ static int fb_notifier_callback(struct notifier_block *self, bd->props.state |= BL_CORE_FBBLANK; bd->props.fb_blank = fb_blank; backlight_update_status(bd); -#ifdef CONFIG_DFX_ZEROHUNG - hung_wp_screen_setblank(fb_blank); -#endif } } out: diff --git a/include/dfx/hung_wp_screen.h b/include/dfx/hung_wp_screen.h index 88bb62435d6a..fa383f267af1 100644 --- a/include/dfx/hung_wp_screen.h +++ b/include/dfx/hung_wp_screen.h @@ -30,7 +30,5 @@ #define WP_SCREEN_OFF_NAME "SCREEN_OFF" void hung_wp_screen_powerkey_ncb(int event); -void hung_wp_screen_setblank(int blank); -int hung_wp_screen_getbl(void); #endif /* HUNG_WP_SCREEN_H */ -- Gitee From cab34d858beb21a0ac330cdf6aacb6aea24f960f Mon Sep 17 00:00:00 2001 From: zhizhimeimei6 Date: Thu, 17 Feb 2022 11:57:10 +0800 Subject: [PATCH 2/3] zerohung,hungtask,hievent: clear code warning ohos inclusion category: bugfix issue: #I4U4X3 CVE: NA ----------------- clear code warning of zerohung, hungtask and hievent Signed-off-by: zhizhimeimei6 --- drivers/staging/hievent/Kconfig | 1 + drivers/staging/hievent/Makefile | 1 + drivers/staging/hievent/hievent_driver.c | 10 ---------- drivers/staging/hievent/hievent_driver.h | 10 ---------- drivers/staging/hievent/hiview_hievent.c | 10 ---------- drivers/staging/hievent/hiview_hievent.h | 10 ---------- drivers/staging/hungtask/Kconfig | 1 + drivers/staging/hungtask/Makefile | 1 + drivers/staging/hungtask/hungtask_base.c | 16 +++------------- drivers/staging/hungtask/hungtask_user.c | 10 ---------- drivers/staging/hungtask/hungtask_user.h | 12 +----------- .../staging/zerohung/watchpoint/hung_wp_screen.c | 10 ---------- drivers/staging/zerohung/zrhung_event.c | 12 +----------- include/dfx/hung_wp_screen.h | 12 +----------- include/dfx/hungtask_base.h | 12 +----------- include/dfx/zrhung.h | 12 +----------- 16 files changed, 12 insertions(+), 128 deletions(-) diff --git a/drivers/staging/hievent/Kconfig b/drivers/staging/hievent/Kconfig index 07834c32ba12..b445a2b90a07 100644 --- a/drivers/staging/hievent/Kconfig +++ b/drivers/staging/hievent/Kconfig @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 config HIEVENT tristate "Enable hievent" help diff --git a/drivers/staging/hievent/Makefile b/drivers/staging/hievent/Makefile index 3d3ff445f5c9..5b2adc23affc 100644 --- a/drivers/staging/hievent/Makefile +++ b/drivers/staging/hievent/Makefile @@ -1 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_HIEVENT) += hievent_driver.o \ No newline at end of file diff --git a/drivers/staging/hievent/hievent_driver.c b/drivers/staging/hievent/hievent_driver.c index 36b0a778e04f..b65dee9392a3 100644 --- a/drivers/staging/hievent/hievent_driver.c +++ b/drivers/staging/hievent/hievent_driver.c @@ -1,16 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2021 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define pr_fmt(fmt) "hievent_driver " fmt diff --git a/drivers/staging/hievent/hievent_driver.h b/drivers/staging/hievent/hievent_driver.h index 5d52982b78f6..83c67d9d2e15 100644 --- a/drivers/staging/hievent/hievent_driver.h +++ b/drivers/staging/hievent/hievent_driver.h @@ -1,16 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2021 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef HIEVENT_DRIVER_H diff --git a/drivers/staging/hievent/hiview_hievent.c b/drivers/staging/hievent/hiview_hievent.c index c72e6f2bb401..4533b6fbb759 100644 --- a/drivers/staging/hievent/hiview_hievent.c +++ b/drivers/staging/hievent/hiview_hievent.c @@ -1,16 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2021 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #include "hiview_hievent.h" diff --git a/drivers/staging/hievent/hiview_hievent.h b/drivers/staging/hievent/hiview_hievent.h index 358a3e8fed4e..c1c003510485 100644 --- a/drivers/staging/hievent/hiview_hievent.h +++ b/drivers/staging/hievent/hiview_hievent.h @@ -1,16 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2021 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef HIVIEW_HIEVENT_H diff --git a/drivers/staging/hungtask/Kconfig b/drivers/staging/hungtask/Kconfig index c7b43fa6eb62..4e80dc9fc434 100644 --- a/drivers/staging/hungtask/Kconfig +++ b/drivers/staging/hungtask/Kconfig @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 config DFX_HUNGTASK bool "DFX hungtask" depends on DETECT_HUNG_TASK diff --git a/drivers/staging/hungtask/Makefile b/drivers/staging/hungtask/Makefile index 24951f2cf42c..12def220e3d6 100644 --- a/drivers/staging/hungtask/Makefile +++ b/drivers/staging/hungtask/Makefile @@ -1,2 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DFX_HUNGTASK) += hungtask_base.o obj-$(CONFIG_DFX_HUNGTASK_USER) += hungtask_user.o diff --git a/drivers/staging/hungtask/hungtask_base.c b/drivers/staging/hungtask/hungtask_base.c index 740a5d1e2578..95c21dd045d2 100644 --- a/drivers/staging/hungtask/hungtask_base.c +++ b/drivers/staging/hungtask/hungtask_base.c @@ -1,16 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define pr_fmt(fmt) "hungtask_base " fmt @@ -403,7 +393,7 @@ void do_show_task(struct task_struct *task, unsigned int flag, int d_state_time) upload.tgid = task->tgid; upload.duration = d_state_time; memset(upload.name, 0, sizeof(upload.name)); - strncpy(upload.name, task->comm, sizeof(task->comm)); + strncpy(upload.name, task->comm, sizeof(upload.name)); upload.flag = flag; if (task->flags & PF_FROZEN) upload.flag = (upload.flag | FLAG_PF_FROZEN); @@ -426,7 +416,7 @@ static void create_taskitem(struct task_item *taskitem, taskitem->pid = task->pid; taskitem->tgid = task->tgid; memset(taskitem->name, 0, sizeof(taskitem->name)); - strncpy(taskitem->name, task->comm, sizeof(task->comm)); + strncpy(taskitem->name, task->comm, sizeof(taskitem->name)); taskitem->switch_count = task->nvcsw + task->nivcsw; taskitem->dump_wa = 0; /* whitelist or applist task dump times */ taskitem->panic_wa = 0; /* whitelist or applist task panic times */ @@ -628,7 +618,7 @@ static void update_panic_task(struct task_item *item) upload.pid = item->pid; upload.tgid = item->tgid; memset(upload.name, 0, sizeof(upload.name)); - strncpy(upload.name, item->name, sizeof(item->name)); + strncpy(upload.name, item->name, sizeof(upload.name)); } static void deal_task(struct task_item *item, struct task_struct *task, bool is_called) diff --git a/drivers/staging/hungtask/hungtask_user.c b/drivers/staging/hungtask/hungtask_user.c index 7070ba197d9b..39b0b1bd5035 100644 --- a/drivers/staging/hungtask/hungtask_user.c +++ b/drivers/staging/hungtask/hungtask_user.c @@ -1,16 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define pr_fmt(fmt) "hungtask_user " fmt diff --git a/drivers/staging/hungtask/hungtask_user.h b/drivers/staging/hungtask/hungtask_user.h index 3cd655cac2d5..17ea7212b21e 100644 --- a/drivers/staging/hungtask/hungtask_user.h +++ b/drivers/staging/hungtask/hungtask_user.h @@ -1,16 +1,6 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef DFX_HUNGTASK_USER_H diff --git a/drivers/staging/zerohung/watchpoint/hung_wp_screen.c b/drivers/staging/zerohung/watchpoint/hung_wp_screen.c index e76fe54f9d20..3b5f2d6daa54 100644 --- a/drivers/staging/zerohung/watchpoint/hung_wp_screen.c +++ b/drivers/staging/zerohung/watchpoint/hung_wp_screen.c @@ -1,16 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define pr_fmt(fmt) "zrhung " fmt diff --git a/drivers/staging/zerohung/zrhung_event.c b/drivers/staging/zerohung/zrhung_event.c index 0ad2d9abb31d..be0428d4edfa 100644 --- a/drivers/staging/zerohung/zrhung_event.c +++ b/drivers/staging/zerohung/zrhung_event.c @@ -1,16 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define pr_fmt(fmt) "zrhung " fmt @@ -117,7 +107,7 @@ struct hisysevent *create_hisysevent(const char *domain, const char *event_name) event = vmalloc(sizeof(*event)); if (!event) { pr_err("failed to vmalloc for event"); - return -ENOMEM; + return NULL; } memset(event, 0, sizeof(*event)); diff --git a/include/dfx/hung_wp_screen.h b/include/dfx/hung_wp_screen.h index fa383f267af1..8b04107e072f 100644 --- a/include/dfx/hung_wp_screen.h +++ b/include/dfx/hung_wp_screen.h @@ -1,16 +1,6 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef HUNG_WP_SCREEN_H diff --git a/include/dfx/hungtask_base.h b/include/dfx/hungtask_base.h index 5c280b5b21b5..b3cf189a0051 100644 --- a/include/dfx/hungtask_base.h +++ b/include/dfx/hungtask_base.h @@ -1,16 +1,6 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef DFX_HUNGTASK_BASE_H diff --git a/include/dfx/zrhung.h b/include/dfx/zrhung.h index 9d54df21c817..4a217c99d39c 100644 --- a/include/dfx/zrhung.h +++ b/include/dfx/zrhung.h @@ -1,16 +1,6 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef ZRHUNG_H -- Gitee From e70c3b09c14ea39b38f7ed89e055b9887694b348 Mon Sep 17 00:00:00 2001 From: zhizhimeimei6 Date: Thu, 17 Feb 2022 21:31:57 +0800 Subject: [PATCH 3/3] zerohung: edit event name ohos inclusion category: bugfix issue: #I4U4X3 CVE: NA ----------------- edit event name to fit hiview Signed-off-by: zhizhimeimei6 --- include/dfx/hung_wp_screen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dfx/hung_wp_screen.h b/include/dfx/hung_wp_screen.h index 8b04107e072f..39bad044c942 100644 --- a/include/dfx/hung_wp_screen.h +++ b/include/dfx/hung_wp_screen.h @@ -14,8 +14,8 @@ #define ZRHUNG_WP_SCREENOFF 2 #define WP_SCREEN_DOMAIN "KERNEL_VENDOR" -#define WP_SCREEN_PWK_NAME "POWERKEY" -#define WP_SCREEN_LPRESS_NAME "LONGPRESS" +#define WP_SCREEN_PWK_NAME "POWER_KEY" +#define WP_SCREEN_LPRESS_NAME "LONG_PRESS" #define WP_SCREEN_ON_NAME "SCREEN_ON" #define WP_SCREEN_OFF_NAME "SCREEN_OFF" -- Gitee