From 3777f3811a7f55ae74707ccfc973b26bc09dd975 Mon Sep 17 00:00:00 2001 From: Jone Chou Date: Sun, 6 Jun 2021 19:20:56 +0800 Subject: [PATCH] ANDROID: kernel: Fix passing NULL to __pa_symbol() If passing ZERO(NULL) to __pa_symbol() would trigger a BUG() when CONFIG_DEBUG_VIRTUAL=y Bug: 190334261 Signed-off-by: Jone Chou Change-Id: I78837a268b7e340f2658e0b831c9f2b5453aa3f0 --- drivers/staging/android/debug_kinfo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/debug_kinfo.c b/drivers/staging/android/debug_kinfo.c index 0975019e70db..69d5a49b0092 100644 --- a/drivers/staging/android/debug_kinfo.c +++ b/drivers/staging/android/debug_kinfo.c @@ -135,14 +135,17 @@ static int debug_kinfo_probe(struct platform_device *pdev) info->bit_per_long = BITS_PER_LONG; info->module_name_len = MODULE_NAME_LEN; info->symbol_len = KSYM_SYMBOL_LEN; - info->_addresses_pa = (u64)__pa_symbol((volatile void *)kallsyms_addresses); - info->_relative_pa = (u64)__pa_symbol((volatile void *)kallsyms_relative_base); + if (!info->enabled_base_relative) + info->_addresses_pa = (u64)__pa_symbol((volatile void *)kallsyms_addresses); + else { + info->_relative_pa = (u64)__pa_symbol((volatile void *)kallsyms_relative_base); + info->_offsets_pa = (u64)__pa_symbol((volatile void *)kallsyms_offsets); + } info->_stext_pa = (u64)__pa_symbol(_stext); info->_etext_pa = (u64)__pa_symbol(_etext); info->_sinittext_pa = (u64)__pa_symbol(_sinittext); info->_einittext_pa = (u64)__pa_symbol(_einittext); info->_end_pa = (u64)__pa_symbol(_end); - info->_offsets_pa = (u64)__pa_symbol((volatile void *)kallsyms_offsets); info->_names_pa = (u64)__pa_symbol((volatile void *)kallsyms_names); info->_token_table_pa = (u64)__pa_symbol((volatile void *)kallsyms_token_table); info->_token_index_pa = (u64)__pa_symbol((volatile void *)kallsyms_token_index);