diff options
| author | Xiang W <[email protected]> | 2025-09-03 12:46:04 +0800 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2025-10-06 14:31:52 +0530 |
| commit | e3eb59a396ac55975e3debecfc5b71418eb62248 (patch) | |
| tree | d9dc88d083bee2a06403d31be3fe12f98bd862fe /lib | |
| parent | 38c31ffb8f8f9aa3730403d8c3812904ad74fb39 (diff) | |
lib: sbi: Prevent target domain same as the current
Add error handling code to sbi_domain_context_enter to prevent the
target domain from being the same as the current domain.
Signed-off-by: Xiang W <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbi/sbi_domain_context.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c index e909670c..5490df28 100644 --- a/lib/sbi/sbi_domain_context.c +++ b/lib/sbi/sbi_domain_context.c @@ -193,6 +193,10 @@ int sbi_domain_context_enter(struct sbi_domain *dom) struct hart_context *dom_ctx; struct hart_context *ctx = hart_context_thishart_get(); + /* Target domain must not be same as the current domain */ + if (!dom || dom == sbi_domain_thishart_ptr()) + return SBI_EINVAL; + /* * If it's first time to call `enter` on the current hart, no * context allocated before. Allocate context for each valid |
