2022-04-27 05:55:50

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] arm64/sme: Fix NULL check after kzalloc

Fix following coccicheck error:
./arch/arm64/kernel/process.c:322:2-23: alloc with no test, possible model on line 326

Here should be dst->thread.sve_state.

Fixes: 8bd7f91c03d8 ("arm64/sme: Implement traps and syscall handling for SME")
Signed-off-by: Wan Jiabing <[email protected]>
---
arch/arm64/kernel/process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 99c293513817..9734c9fb1a32 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -321,7 +321,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
if (thread_za_enabled(&src->thread)) {
dst->thread.sve_state = kzalloc(sve_state_size(src),
GFP_KERNEL);
- if (!dst->thread.za_state)
+ if (!dst->thread.sve_state)
return -ENOMEM;
dst->thread.za_state = kmemdup(src->thread.za_state,
za_state_size(src),
--
2.35.3


2022-04-30 16:25:28

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH] arm64/sme: Fix NULL check after kzalloc

On Tue, 26 Apr 2022 19:30:53 +0800, Wan Jiabing wrote:
> Fix following coccicheck error:
> ./arch/arm64/kernel/process.c:322:2-23: alloc with no test, possible model on line 326
>
> Here should be dst->thread.sve_state.
>
>

Applied to arm64 (for-next/sme), thanks!

[1/1] arm64/sme: Fix NULL check after kzalloc
https://git.kernel.org/arm64/c/2e29b9971ac5

--
Catalin