diff options
author | Russell Currey <ruscur@russell.cc> | 2023-02-10 19:03:40 +1100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-02-12 22:12:36 +1100 |
commit | 26149b02021158248b13e323f06372d87f076883 (patch) | |
tree | a51bb3bd4339839314d256dba48f78561fc4a5dd /arch/powerpc/kernel/secvar-ops.c | |
parent | 53cea34b0a0a03568e189f8dfe2eb06f938986c8 (diff) | |
download | lwn-26149b02021158248b13e323f06372d87f076883.tar.gz lwn-26149b02021158248b13e323f06372d87f076883.zip |
powerpc/secvar: Warn and error if multiple secvar ops are set
The secvar code only supports one consumer at a time.
Multiple consumers aren't possible at this point in time, but we'd want
it to be obvious if it ever could happen.
Signed-off-by: Russell Currey <ruscur@russell.cc>
Co-developed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230210080401.345462-6-ajd@linux.ibm.com
Diffstat (limited to 'arch/powerpc/kernel/secvar-ops.c')
-rw-r--r-- | arch/powerpc/kernel/secvar-ops.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/secvar-ops.c b/arch/powerpc/kernel/secvar-ops.c index 6a29777d6a2d..19172a2804f0 100644 --- a/arch/powerpc/kernel/secvar-ops.c +++ b/arch/powerpc/kernel/secvar-ops.c @@ -8,10 +8,16 @@ #include <linux/cache.h> #include <asm/secvar.h> +#include <asm/bug.h> -const struct secvar_operations *secvar_ops __ro_after_init; +const struct secvar_operations *secvar_ops __ro_after_init = NULL; -void set_secvar_ops(const struct secvar_operations *ops) +int set_secvar_ops(const struct secvar_operations *ops) { + if (WARN_ON_ONCE(secvar_ops)) + return -EBUSY; + secvar_ops = ops; + + return 0; } |