mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
lib: dhry: fix sleeping allocations inside non-preemptable section
[ Upstream commit8ba388c06b
] The Smatch static checker reports the following warnings: lib/dhry_run.c:38 dhry_benchmark() warn: sleeping in atomic context lib/dhry_run.c:43 dhry_benchmark() warn: sleeping in atomic context Indeed, dhry() does sleeping allocations inside the non-preemptable section delimited by get_cpu()/put_cpu(). Fix this by using atomic allocations instead. Add error handling, as atomic these allocations may fail. Link: https://lkml.kernel.org/r/bac6d517818a7cd8efe217c1ad649fffab9cc371.1688568764.git.geert+renesas@glider.be Fixes:13684e966d
("lib: dhry: fix unstable smp_processor_id(_) usage") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/0469eb3a-02eb-4b41-b189-de20b931fa56@moroto.mountain Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e22ca18614
commit
64c79e58a7
1 changed files with 9 additions and 2 deletions
11
lib/dhry_1.c
11
lib/dhry_1.c
|
@ -139,8 +139,15 @@ int dhry(int n)
|
||||||
|
|
||||||
/* Initializations */
|
/* Initializations */
|
||||||
|
|
||||||
Next_Ptr_Glob = (Rec_Pointer)kzalloc(sizeof(Rec_Type), GFP_KERNEL);
|
Next_Ptr_Glob = (Rec_Pointer)kzalloc(sizeof(Rec_Type), GFP_ATOMIC);
|
||||||
Ptr_Glob = (Rec_Pointer)kzalloc(sizeof(Rec_Type), GFP_KERNEL);
|
if (!Next_Ptr_Glob)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
Ptr_Glob = (Rec_Pointer)kzalloc(sizeof(Rec_Type), GFP_ATOMIC);
|
||||||
|
if (!Ptr_Glob) {
|
||||||
|
kfree(Next_Ptr_Glob);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
|
Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
|
||||||
Ptr_Glob->Discr = Ident_1;
|
Ptr_Glob->Discr = Ident_1;
|
||||||
|
|
Loading…
Reference in a new issue