[prev in list] [next in list] [prev in thread] [next in thread]
List: xen-cvs
Subject: [xen master] domain: add ASSERT to help static analysis tools
From: patchbot () xen ! org
Date: 2023-11-30 12:35:33
Message-ID: E1r8gGT-0005W9-Ed () xenbits ! xenproject ! org
[Download RAW message or body]
commit caa221791d4214445f2913f51a3230cc5644ab8d
Author: Nicola Vetrini <nicola.vetrini@bugseng.com>
AuthorDate: Fri Nov 17 10:21:52 2023 +0100
Commit: Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Tue Nov 28 19:12:53 2023 -0800
domain: add ASSERT to help static analysis tools
Static analysis tools may detect a possible null pointer
dereference of 'config'. This ASSERT helps them in detecting
that such a condition is not possible given that only
real domains can enter this branch, which are guaranteeed to have
a non-NULL config at this point, but this information is not
inferred by the tool.
Checking that the condition given in the assertion holds via
testing is the means to protect release builds, where the assertion
expands to effectively nothing.
Suggested-by: Julien Grall <julien@xen.org>
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
xen/common/domain.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/xen/common/domain.c b/xen/common/domain.c
index f15c2f1e95..cd2ca6d49a 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -700,6 +700,13 @@ struct domain *domain_create(domid_t domid,
if ( !is_idle_domain(d) )
{
+ /*
+ * The assertion helps static analysis tools infer that config cannot
+ * be NULL in this branch, which in turn means that it can be safely
+ * dereferenced. Therefore, this assertion is not redundant.
+ */
+ ASSERT(config);
+
watchdog_domain_init(d);
init_status |= INIT_watchdog;
--
generated by git-patchbot for /home/xen/git/xen.git#master
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic