In plpks_gen_wrapping_key() and plpks_wrap_object(), strlen(var.name) is used to initialize var.namelen within the same struct initializer. This references a member of var before initialization of var is complete.
Use the compile-time length of PLPKS_DEFAULT_WRAPKEY_LABEL instead. Reported-by: R Nageswara Sastry <[email protected]> Fixes: 133aa79e211d ("pseries/plpks: add HCALLs for PowerVM Key Wrapping Module") Cc: [email protected] Signed-off-by: Srish Srinivasan <[email protected]> --- arch/powerpc/platforms/pseries/plpks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c index b553f7b130b6..d582c786ccad 100644 --- a/arch/powerpc/platforms/pseries/plpks.c +++ b/arch/powerpc/platforms/pseries/plpks.c @@ -939,7 +939,7 @@ int plpks_gen_wrapping_key(void) int rc = 0, pseries_status = 0; struct plpks_var var = { .name = PLPKS_DEFAULT_WRAPKEY_LABEL, - .namelen = strlen(var.name), + .namelen = sizeof(PLPKS_DEFAULT_WRAPKEY_LABEL) - 1, .policy = PLPKS_WRAPPINGKEY, .os = PLPKS_VAR_LINUX, .component = PLPKS_WRAPKEY_COMPONENT @@ -1034,7 +1034,7 @@ int plpks_wrap_object(u8 **input_buf, u64 input_len, u16 wrap_flags, bool sb_enforce_bit = wrap_flags & BIT(1); struct plpks_var var = { .name = PLPKS_DEFAULT_WRAPKEY_LABEL, - .namelen = strlen(var.name), + .namelen = sizeof(PLPKS_DEFAULT_WRAPKEY_LABEL) - 1, .os = PLPKS_VAR_LINUX, .component = PLPKS_WRAPKEY_COMPONENT }; -- 2.52.0
