diff mbox series

[5/6] powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver

Message ID 20221106205839.600442-6-nayna@linux.ibm.com (mailing list archive)
State Accepted
Commit 212dd5cfbee7815f3c665a51c501701edb881599
Headers show
Series powerpc/pseries - bugfixes/cleanups for PLPKS driver | expand

Commit Message

Nayna Jain Nov. 6, 2022, 8:58 p.m. UTC
Replace kmalloc with kzalloc in construct_auth() function to default
initialize structure with zeroes.

Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
 arch/powerpc/platforms/pseries/plpks.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Andrew Donnellan Nov. 25, 2022, 3:31 a.m. UTC | #1
On Sun, 2022-11-06 at 15:58 -0500, Nayna Jain wrote:
> Replace kmalloc with kzalloc in construct_auth() function to default
> initialize structure with zeroes.
> 
> Signed-off-by: Nayna Jain <nayna@linux.ibm.com>

This seems sensible.

> ---
>  arch/powerpc/platforms/pseries/plpks.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/plpks.c
> b/arch/powerpc/platforms/pseries/plpks.c
> index 72d9debf18c0..e8c02735b702 100644
> --- a/arch/powerpc/platforms/pseries/plpks.c
> +++ b/arch/powerpc/platforms/pseries/plpks.c
> @@ -162,19 +162,15 @@ static struct plpks_auth *construct_auth(u8
> consumer)
>         if (consumer > PKS_OS_OWNER)
>                 return ERR_PTR(-EINVAL);
>  
> -       auth = kmalloc(struct_size(auth, password, maxpwsize),
> GFP_KERNEL);
> +       auth = kzalloc(struct_size(auth, password, maxpwsize),
> GFP_KERNEL);
>         if (!auth)
>                 return ERR_PTR(-ENOMEM);
>  
>         auth->version = 1;
>         auth->consumer = consumer;
> -       auth->rsvd0 = 0;
> -       auth->rsvd1 = 0;
>  
> -       if (consumer == PKS_FW_OWNER || consumer ==
> PKS_BOOTLOADER_OWNER) {
> -               auth->passwordlength = 0;
> +       if (consumer == PKS_FW_OWNER || consumer ==
> PKS_BOOTLOADER_OWNER)

>                 return auth;
> -       }

This bit seems spurious.

>  
>         memcpy(auth->password, ospassword, ospasswordlength);
>
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
index 72d9debf18c0..e8c02735b702 100644
--- a/arch/powerpc/platforms/pseries/plpks.c
+++ b/arch/powerpc/platforms/pseries/plpks.c
@@ -162,19 +162,15 @@  static struct plpks_auth *construct_auth(u8 consumer)
 	if (consumer > PKS_OS_OWNER)
 		return ERR_PTR(-EINVAL);
 
-	auth = kmalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
+	auth = kzalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
 	if (!auth)
 		return ERR_PTR(-ENOMEM);
 
 	auth->version = 1;
 	auth->consumer = consumer;
-	auth->rsvd0 = 0;
-	auth->rsvd1 = 0;
 
-	if (consumer == PKS_FW_OWNER || consumer == PKS_BOOTLOADER_OWNER) {
-		auth->passwordlength = 0;
+	if (consumer == PKS_FW_OWNER || consumer == PKS_BOOTLOADER_OWNER)
 		return auth;
-	}
 
 	memcpy(auth->password, ospassword, ospasswordlength);