[1/2] ARM: kprobes: Improve robustness for kprobe coverage testing

Message ID 20221103011645.138749-1-liaochang1@huawei.com
State New
Headers
Series [1/2] ARM: kprobes: Improve robustness for kprobe coverage testing |

Commit Message

Liao Chang Nov. 3, 2022, 1:16 a.m. UTC
  Improve robustness for kprobe coverage testing, avoid to access NULL
pointer in coverage_start_fn.

Fixes: 963780dfe390 ("ARM: kprobes: Add decoding table test coverage analysis")
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
 arch/arm/probes/kprobes/test-core.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/arch/arm/probes/kprobes/test-core.c b/arch/arm/probes/kprobes/test-core.c
index c562832b8627..e6a932e863bb 100644
--- a/arch/arm/probes/kprobes/test-core.c
+++ b/arch/arm/probes/kprobes/test-core.c
@@ -766,6 +766,11 @@  static int coverage_start(const union decode_item *table)
 	coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
 				      sizeof(struct coverage_entry),
 				      GFP_KERNEL);
+	if (!coverage.base) {
+		pr_err("FAIL: Out of space for allocating coverage entries");
+		return -ENOMEM;
+	}
+
 	coverage.num_entries = 0;
 	coverage.nesting = 0;
 	return table_iter(table, coverage_start_fn, &coverage);