All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ksmbd: Remove a redundant zeroing of memory
@ 2022-03-23  6:32 Christophe JAILLET
  2022-03-23 13:51 ` Namjae Jeon
  2022-03-24 14:46 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-03-23  6:32 UTC (permalink / raw)
  To: Namjae Jeon, Sergey Senozhatsky, Steve French, Hyunchul Lee
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-cifs

fill_transform_hdr() has only one caller that already clears tr_buf (it is
kzalloc'ed).

So there is no need to clear it another time here.

Remove the superfluous memset() and add a comment to remind that the caller
must clear the buffer.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v2: keep kzalloc in the caller and remove the memset here
---
 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..bcd1bb7e2856 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -8410,7 +8410,7 @@ static void fill_transform_hdr(void *tr_buf, char *old_buf, __le16 cipher_type)
 	struct smb2_hdr *hdr = smb2_get_msg(old_buf);
 	unsigned int orig_len = get_rfc1002_len(old_buf);
 
-	memset(tr_buf, 0, sizeof(struct smb2_transform_hdr) + 4);
+	/* tr_buf must be cleared by the caller */
 	tr_hdr->ProtocolId = SMB2_TRANSFORM_PROTO_NUM;
 	tr_hdr->OriginalMessageSize = cpu_to_le32(orig_len);
 	tr_hdr->Flags = cpu_to_le16(TRANSFORM_FLAG_ENCRYPTED);
-- 
2.32.0


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

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

2022-03-23 15:32 GMT+09:00, Christophe JAILLET <christophe.jaillet@wanadoo.fr>:
> fill_transform_hdr() has only one caller that already clears tr_buf (it is
> kzalloc'ed).
>
> So there is no need to clear it another time here.
>
> Remove the superfluous memset() and add a comment to remind that the caller
> must clear the buffer.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>

Thanks!

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

* Re: [PATCH v2] ksmbd: Remove a redundant zeroing of memory
  2022-03-23  6:32 [PATCH v2] ksmbd: Remove a redundant zeroing of memory Christophe JAILLET
  2022-03-23 13:51 ` Namjae Jeon
@ 2022-03-24 14:46 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-03-24 14:46 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 07:32:05AM +0100, Christophe JAILLET wrote:
> fill_transform_hdr() has only one caller that already clears tr_buf (it is
> kzalloc'ed).
> 
> So there is no need to clear it another time here.
> 
> Remove the superfluous memset() and add a comment to remind that the caller
> must clear the buffer.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> v2: keep kzalloc in the caller and remove the memset here

I kind of prefered v1.  I misread the code and was looking at the wrong
fill_transform_hdr() function from the other driver.

regards,
dan carpenter


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

end of thread, other threads:[~2022-03-24 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23  6:32 [PATCH v2] ksmbd: Remove a redundant zeroing of memory Christophe JAILLET
2022-03-23 13:51 ` Namjae Jeon
2022-03-24 14:46 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.