linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ksmbd: Remove a redundant zeroing of memory
@ 2022-03-22 20:29 Christophe JAILLET
  2022-03-22 22:27 ` Hyunchul Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christophe JAILLET @ 2022-03-22 20:29 UTC (permalink / raw)
  To: Namjae Jeon, Sergey Senozhatsky, Steve French, Hyunchul Lee
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-cifs

fill_transform_hdr() already call memset(0) on its 1st argument, so there
is no need to clear it explicitly before calling this function.

Use kmalloc() instead of kzalloc() to save a few cycles.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Alternatively, fill_transform_hdr() has only one caller. So its memset()
could be removed instead and this kzalloc() left as is.
---
 fs/ksmbd/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index bcb98109bac9..0e4f819e5859 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -8434,7 +8434,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
 	if (ARRAY_SIZE(iov) < rq_nvec)
 		return -ENOMEM;
 
-	work->tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
+	work->tr_buf = kmalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
 	if (!work->tr_buf)
 		return rc;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ksmbd: Remove a redundant zeroing of memory
  2022-03-22 20:29 [PATCH] ksmbd: Remove a redundant zeroing of memory Christophe JAILLET
@ 2022-03-22 22:27 ` Hyunchul Lee
  2022-03-22 23:38 ` Namjae Jeon
  2022-03-23  6:51 ` Dan Carpenter
  2 siblings, 0 replies; 5+ messages in thread
From: Hyunchul Lee @ 2022-03-22 22:27 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Namjae Jeon, Sergey Senozhatsky, Steve French, LKML,
	kernel-janitors, linux-cifs

Acked-by: Hyunchul Lee <hyc.lee@gmail.com>

2022년 3월 23일 (수) 오전 5:29, Christophe JAILLET
<christophe.jaillet@wanadoo.fr>님이 작성:
>
> fill_transform_hdr() already call memset(0) on its 1st argument, so there
> is no need to clear it explicitly before calling this function.
>
> Use kmalloc() instead of kzalloc() to save a few cycles.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Alternatively, fill_transform_hdr() has only one caller. So its memset()
> could be removed instead and this kzalloc() left as is.
> ---
>  fs/ksmbd/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index bcb98109bac9..0e4f819e5859 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -8434,7 +8434,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
>         if (ARRAY_SIZE(iov) < rq_nvec)
>                 return -ENOMEM;
>
> -       work->tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
> +       work->tr_buf = kmalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
>         if (!work->tr_buf)
>                 return rc;
>
> --
> 2.32.0
>


-- 
Thanks,
Hyunchul

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ksmbd: Remove a redundant zeroing of memory
  2022-03-22 20:29 [PATCH] ksmbd: Remove a redundant zeroing of memory Christophe JAILLET
  2022-03-22 22:27 ` Hyunchul Lee
@ 2022-03-22 23:38 ` Namjae Jeon
  2022-03-23  6:51 ` Dan Carpenter
  2 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2022-03-22 23:38 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Sergey Senozhatsky, Steve French, Hyunchul Lee, linux-kernel,
	kernel-janitors, linux-cifs

2022-03-23 5:29 GMT+09:00, Christophe JAILLET <christophe.jaillet@wanadoo.fr>:
> fill_transform_hdr() already call memset(0) on its 1st argument, so there
> is no need to clear it explicitly before calling this function.
>
> Use kmalloc() instead of kzalloc() to save a few cycles.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Alternatively, fill_transform_hdr() has only one caller. So its memset()
> could be removed instead and this kzalloc() left as is.
I prefer this. Could you update the patch ?

Thanks!
> ---
>  fs/ksmbd/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index bcb98109bac9..0e4f819e5859 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -8434,7 +8434,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
>  	if (ARRAY_SIZE(iov) < rq_nvec)
>  		return -ENOMEM;
>
> -	work->tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4,
> GFP_KERNEL);
> +	work->tr_buf = kmalloc(sizeof(struct smb2_transform_hdr) + 4,
> GFP_KERNEL);
>  	if (!work->tr_buf)
>  		return rc;
>
> --
> 2.32.0
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ksmbd: Remove a redundant zeroing of memory
  2022-03-22 20:29 [PATCH] ksmbd: Remove a redundant zeroing of memory Christophe JAILLET
  2022-03-22 22:27 ` Hyunchul Lee
  2022-03-22 23:38 ` Namjae Jeon
@ 2022-03-23  6:51 ` Dan Carpenter
  2022-03-23 12:21   ` Dan Carpenter
  2 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2022-03-23  6:51 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Namjae Jeon, Sergey Senozhatsky, Steve French, Hyunchul Lee,
	linux-kernel, kernel-janitors, linux-cifs

On Tue, Mar 22, 2022 at 09:29:51PM +0100, Christophe JAILLET wrote:
> fill_transform_hdr() already call memset(0) on its 1st argument, so there
> is no need to clear it explicitly before calling this function.
> 
> Use kmalloc() instead of kzalloc() to save a few cycles.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Alternatively, fill_transform_hdr() has only one caller. So its memset()
> could be removed instead and this kzalloc() left as is.
> ---
>  fs/ksmbd/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index bcb98109bac9..0e4f819e5859 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -8434,7 +8434,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
>  	if (ARRAY_SIZE(iov) < rq_nvec)
>  		return -ENOMEM;
>  
> -	work->tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
> +	work->tr_buf = kmalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
                                                                 ^^^
fill_transform_hdr() does not clear the last 4 bytes.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ksmbd: Remove a redundant zeroing of memory
  2022-03-23  6:51 ` Dan Carpenter
@ 2022-03-23 12:21   ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2022-03-23 12:21 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Namjae Jeon, Sergey Senozhatsky, Steve French, Hyunchul Lee,
	linux-kernel, kernel-janitors, linux-cifs

On Wed, Mar 23, 2022 at 09:51:11AM +0300, Dan Carpenter wrote:
> On Tue, Mar 22, 2022 at 09:29:51PM +0100, Christophe JAILLET wrote:
> > fill_transform_hdr() already call memset(0) on its 1st argument, so there
> > is no need to clear it explicitly before calling this function.
> > 
> > Use kmalloc() instead of kzalloc() to save a few cycles.
> > 
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> > Alternatively, fill_transform_hdr() has only one caller. So its memset()
> > could be removed instead and this kzalloc() left as is.
> > ---
> >  fs/ksmbd/smb2pdu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> > index bcb98109bac9..0e4f819e5859 100644
> > --- a/fs/ksmbd/smb2pdu.c
> > +++ b/fs/ksmbd/smb2pdu.c
> > @@ -8434,7 +8434,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
> >  	if (ARRAY_SIZE(iov) < rq_nvec)
> >  		return -ENOMEM;
> >  
> > -	work->tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
> > +	work->tr_buf = kmalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL);
>                                                                  ^^^
> fill_transform_hdr() does not clear the last 4 bytes.
> 

Oops.  I was looking at the wrong fill_transform_hdr() from smb2ops.c
instead of smb2pdu.c.  Sorry!

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-23 12:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 20:29 [PATCH] ksmbd: Remove a redundant zeroing of memory Christophe JAILLET
2022-03-22 22:27 ` Hyunchul Lee
2022-03-22 23:38 ` Namjae Jeon
2022-03-23  6:51 ` Dan Carpenter
2022-03-23 12:21   ` Dan Carpenter

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).