* [PATCH -next] secretmem: use ATOMIC_INIT() to initialize secretmem_users
@ 2022-09-06 9:36 Xiu Jianfeng
2022-09-07 5:58 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Xiu Jianfeng @ 2022-09-06 9:36 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel
The variable secretmem_users is of atomic_t type, so initialize it
properly with ATOMIC_INIT().
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
mm/secretmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/secretmem.c b/mm/secretmem.c
index e3e9590c6fb3..796d3a92992a 100644
--- a/mm/secretmem.c
+++ b/mm/secretmem.c
@@ -40,7 +40,7 @@ module_param_named(enable, secretmem_enable, bool, 0400);
MODULE_PARM_DESC(secretmem_enable,
"Enable secretmem and memfd_secret(2) system call");
-static atomic_t secretmem_users;
+static atomic_t secretmem_users = ATOMIC_INIT(0);
bool secretmem_active(void)
{
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] secretmem: use ATOMIC_INIT() to initialize secretmem_users
2022-09-06 9:36 [PATCH -next] secretmem: use ATOMIC_INIT() to initialize secretmem_users Xiu Jianfeng
@ 2022-09-07 5:58 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2022-09-07 5:58 UTC (permalink / raw)
To: Xiu Jianfeng; +Cc: linux-mm, linux-kernel
On Tue, 6 Sep 2022 17:36:20 +0800 Xiu Jianfeng <xiujianfeng@huawei.com> wrote:
> The variable secretmem_users is of atomic_t type, so initialize it
> properly with ATOMIC_INIT().
>
True, but there are many many cases where we initialize an atomic_t to
the all-zeroes pattern. So many that this should be considered
acceptable practice.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-07 5:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 9:36 [PATCH -next] secretmem: use ATOMIC_INIT() to initialize secretmem_users Xiu Jianfeng
2022-09-07 5:58 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).